Reputation: 11
I am using linked oauth 2 api to fetch the access token.But I am getting a 400 (BadRequest) response from that api.I am sharing the code below
NameValueCollection parameters = new NameValueCollection();
parameters.Add("grant_type", "authorization_code");
parameters.Add("code", Code);
parameters.Add("redirect_uri", RedirectURL);
parameters.Add("client_id", ClientId);
parameters.Add("client_secret", ClientSecret);
WebClient client = new WebClient();
client.Headers[HttpRequestHeader.ContentType]="application/x-www-form-urlencoded";
var result = client.UploadValues("https://www.linkedin.com/oauth/v2/accessToken", parameters);
Could anyone help me to find what went wrong here. I am passing the correct values for all parameters, got client_id
, client_secret
from my application and the code I am getting from my initial authorization request.
I am not able to test this scenario in postman since the auth-token request depends on the code generated from the authorization step.
Upvotes: 0
Views: 2342
Reputation: 148
AuthorizationUrl must look like this
Access Token Url will look like this,
And your Params are missing with
QUESTION_MARK (?) after https://www.linkedin.com/oauth/v2/accessToken
your Grant type param must include grant_type=authorization_code than & param than client_id=YourApiKey than & param than redirect_uri=YourRedirectUri than & than client_secret=YourSecretKey
Upvotes: 1