I'm actually trying to do a simple login with Linkedin and the new API V2 with Xamarin.Auth extension. I do get the token like this
var auth = new OAuth2Authenticator(
clientId: *****,
clientSecret: *****,
scope: "r_liteprofile",
authorizeUrl: new Uri("https://www.linkedin.com/oauth/v2/authorization"),
redirectUrl: new Uri(*****),
accessTokenUrl: new Uri("https://www.linkedin.com/oauth/v2/accessToken")
);
but when I try to make a request it fails with an {"serviceErrorCode":100,"message":"Unpermitted fields present in PARAMETER: Data Processing Exception while processing fields [/access_token, /format]","status":403}. Code for these error:
var request = new OAuth2Request(
"GET",
new System.Uri("https://api.linkedin.com/v2/me?"
+ "format=json"
+ "&oauth2_access_token="
+ e.Account.Properties["access_token"]),
null,
e.Account
);
var linkedinResponse = await request.GetResponseAsync();
var json = linkedinResponse.GetResponseText();
Console.WriteLine(json);
If I take out the fields, it fails because of empty access token: {"serviceErrorCode":65604,"message":"Empty oauth2 access token","status":401} Code for these error:
var request = new OAuth2Request(
"GET",
new System.Uri("https://api.linkedin.com/v2/me"),
null,
e.Account
);
var linkedinResponse = await request.GetResponseAsync();
var json = linkedinResponse.GetResponseText();
Console.WriteLine(json);
I've confirmed that I've recieved the token. Looking for a solution I found that the token must be in a header but I can't change or add any header. Can anyone help me please?
Thank you very much.
PD: Forgot to say this code is for Android but I needed to do it for iOS aswell.