Can't understand authentication process
ilyanoskov opened this issue · 3 comments
I have been trying to use this instagram library and I have not had much success yet. I am a beginning Javascript developer and I was trying to write a simple client-side application that would authorize a user through your library and display user's full name in console. For example I would write something like this in console :
node app.js (my instagram name)
and it would return
full name is FULLNAME.
How could I implement this?
I do not understand what code I need to put where CODE is?
var Nodegram = require('nodegram');
var options = {
clientId: ' 243b1a35a618xczxcz644db8zxczsc4d9d9e2d1caaacb7be0',
clientSecret: '3dd3f8120a874zcczxc3169e7e1ff04f46czz6c8',
redirectUri: 'http://localhost:8080'
};
var gram = new Nodegram(options);
var url = gram.getAuthUrl();
var code = 'CODE';
var gram = gram.getAccessToken(code).then(function(res) {
var token = res.access_token;
console.log(token);
return new Nodegram({accessToken: token});
});
//console.log(gram);
as you can see I was trying to print out the access token so I would know that authentication worked out but it seems like it did not.
@ilyanoskov
Any luck?
Did it work? I'm happy to try to help. Also, make sure to never paste your API keys in public. Always store them in your bash or some hidden file within your directory. I prefer the former method and accessing them via the node process object. You can read more about how to do it here: https://medium.com/@rafaelvidaurre/managing-environment-variables-in-node-js-2cb45a55195f @ilyanoskov
You can check this library:
https://github.com/venits/instagram-web-oauth
It is the easiest way of getting access_token from Instagram right now.