0
votes

Need help in integration of onedrive with php web application. Currently i have got stuck while performing below operation:-

  1. I am following this "https://docs.microsoft.com/en-us/onedrive/developer/" doc to integrate it.

  2. First registered my app in "Microsoft Application Registration Portal" through my account "https://login.microsoftonline.com". There it asked few details regarding my application -> redirect url and i generated Client ID and client Secrete which will be needed while using onedrive API.

  3. In authentication process i followed Microsoft Graph -> code flow.

  4. Made API call "GET https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id={client_id}&scope={scope} &response_type=code&redirect_uri={redirect_uri}". Specified the required details and i got proper response. i.e "https://myapp.com/auth-redirect?code=df6aa589-1080-b241-b410-c4dff65dbf7c" from which i got the code.

  5. Now using this code i have to get Access token in which i am failing. So for that i am making API call as mentioned in doc. i.e "POST https://login.microsoftonline.com/common/oauth2/v2.0/token Content-Type: application/x-www-form-urlencoded

    client_id={client_id}&redirect_uri={redirect_uri}&client_secret={client_secret} &code={code}&grant_type=authorization_code"

Above i am passing the same client secrete which i generated while creating the app. But still i am not getting the Access token instead i receive response as:-

{"error":"invalid_client","error_description":"AADSTS70002: Error validating credentials. AADSTS50012: Invalid client secret is provided...}

I tried few other option also like regenerating the new secret key and also urlencoding but was of no use. Please help me out as i am not able to move forward from here. Thanks in advance for help.

1

1 Answers

0
votes

Figured out the issue. Basically the issue was w.r.t the secret key generated. In the "Microsoft Application Registration Portal" where we register our app, there while generating application secret i was using "Generate New key pair" option to generate the sceret instead we have to use the secret genearted by clicking other option "Generate New Password".