Setting up "SteemConnect V2" with React.js
![](https://steemitimages.com/640x0/https://i.imgur.com/6zvBBMM.png)
-"John Johnson".
fortrabbit.github.io/quotes
![](https://steemitimages.com/0x0/https://78.media.tumblr.com/3d6a33fd232b15653d9ea6427e4e7cdd/tumblr_ohh98sIjw41vr75k3o1_500.gif)
So let's stop the talk and let's get into it.
First of all. You need to configure Steemconnect v2. So I will leave here a link, in witch it tells you step by step how to do it properly.
How to configure SteemConnect v2 - By @noisy
Once the APP is set from Steemconnect we can begin to prepare the environment that we will need.
![](https://steemitimages.com/DQmdYE66KsdUJ7erQoUPuMErfk36K664MNDTAAHLzvvJTzu/m81kCVH.png)
Them are: npm install cross-fetch --save
npm install js-cookie --save
With this ready, let's move to our next step.
![](https://steemitimages.com/640x0/https://steemitimages.com/DQmdTyJWF5yaDQaNHmA2B52ZQtK9cx88mDuuaZiZWbMHNf5/Screen%20Shot%202018-04-26%20at%2019.16.28.png)
Edited: on scope, 'login' is an invalid scope. So guys, don't set it as I did.
With this ready, we just need a way to GET the link that the user needs to login with SteemConnect. For that, the API provides us with 2 methods. Both them are for authentication. One of them provides the main link to login, and the other one, just revokes the token, and logs out the user.
![](https://steemitimages.com/DQmU5bWMGWQkdtDfYNMd5ei64A1puxoWVri5t9mqX2wDz6u/Screen%20Shot%202018-04-26%20at%2019.22.23.png)
As you can see in the revokeToken method, we use the Cookie.remove('access_token'). Basically the Cookie package will help us to get the main 'access_token' to the entire site, or remove it in case we don't need it anymore.
Right now we just need a way to set the 'access_token'. I will provide you with my own method. Im sure you can improve it and use regex in a better way, but for now im sure this one will works perfectly for you.
![](https://steemitimages.com/640x0/https://steemitimages.com/DQmQZzbjLvmccZPUqT3LqxZmYCGbKNqUEnLAvoEArArkGg2/Screen%20Shot%202018-04-26%20at%2019.27.38.png)
Damn, a lot of promises. Im sure you can delete most of them, and clean this code a bit. But basically, after the user hits the /success url path, we initialize this method in our componentDidMount.
Basically we are extracting the 'access_token' and setting it to our global Cookie. With that, we are ready to get all the info that the steem blockchain has to offer for us.
![](https://steemitimages.com/DQmdYE66KsdUJ7erQoUPuMErfk36K664MNDTAAHLzvvJTzu/m81kCVH.png)
After this, we just need to call our setAPIToken in our componentDidMount.
![](https://steemitimages.com/640x0/https://steemitimages.com/DQmW6Ksus4MD42wJvF8D7RMndqjaqHSKpP7qp69UZznUCwZ/Screen%20Shot%202018-04-26%20at%2019.34.14.png)
And if we did things right, with the API.me() method, we will be able to get all the info that the blockchain provides from the logged in user.
![](https://steemitimages.com/DQmYMbBjUYM1ddk8hcWqjZ9pB9Ru8BSxHiuzGPqZbF7vPEw/Screen%20Shot%202018-04-26%20at%2019.40.47.png)
![](https://steemitimages.com/640x0/https://steemitimages.com/DQmdYE66KsdUJ7erQoUPuMErfk36K664MNDTAAHLzvvJTzu/m81kCVH.png)
Hope you liked this post, and helped you a bit. See you in the next one! Have a great day everyone!
The thumbnail of the post, was created by me. The gifs of this post, does not belongs to me.
This post was created on steemit.com. As i know on busy.org, the posts didn't looks in the same way. So if you wanna enjoy it, i fully recommend taking a look at the post here on Steemit.
Thanks you!
@selected
great tutorial sir @selected. Go on sir.
Thanks sir : )
welcome sir
Thanks tell me I am resteem due to more peoples read
@selected
Thanks for sharing this great post sir@selected. Great tutorial..it's appreciate me sir. keep going sir.
Your Post Has Been Featured on @Resteemable!
Feature any Steemit post using resteemit.com!
How It Works:
1. Take Any Steemit URL
2. Erase
https://
3. Type
re
Get Featured Instantly & Featured Posts are voted every 2.4hrs
Join the Curation Team Here | Vote Resteemable for Witness