Reputation: 1094
I'm trying to use ng2-cordova-oauth to login with linkedin using cordova. but I'm getting this error when trying to login:
The redirect_uri does not match the registered value.
This is my linkedin provider object:
private linkedinProvider: LinkedIn = new LinkedIn({
clientId: "XXXX",
appScope: ["r_fullprofile"],
});
and this is how I used it:
this.cordovaOauth.logInVia(this.linkedinProvider).then(success => {
console.log("RESULT: " + JSON.stringify(success));
}, error => {
console.log("ERROR: ", error);
});
The problem is that the other parameters linkedin requires aren't available, the ones that are mentioned here in step2 : https://developer.linkedin.com/docs/oauth2
how am I going to add them and use it, the facebook example has only these params, and when I try to add any of the linkedin params I get a compilation error:
const provider = new Facebook({
clientId: string,
appScope?: string[],
redirectUri?: string,
responseType?: string,
authType?: string
});
Upvotes: 0
Views: 660
Reputation: 1094
The linkedin provider should look like this:
private linkedinProvider: LinkedIn = new LinkedIn({
clientId: client_id,
appScope: ["r_basicprofile","r_emailaddress"],
redirectUri: redirectUri,
responseType: responseType,
state: state
});
with responseType is always equal to 'code' and redirectUri always equal 'http://localhost/callback'. and state is a string value that you generate randomly. you'll find client_id and client_secret values in your linkedin app page. the "logInVia" function will return a promise containing the authorization_code, when you get it you'll need to get the access token and with it you issue another request to get the data you want.
the whole requests are documented here in step 3 and step 4. P.S: in step 4 don't forget the "Bearer" before the access token in the Authorization header.
Upvotes: 1