Search code examples
c#windows-7clientonedrivelive-sdk

Sign in to OneDrive without typing user informations


I need help to obtain an authorize code, is there any way to get one without accepting anything or any window that pops up. I need this for my service as an automated process. I tried like a thousand ways but nothing works. Please does anyone know a solution?


Solution

  • As per the docs (http://msdn.microsoft.com/en-us/library/dn659750.aspx), you can use a refresh token if your app has offline access in its scope.

    If offline access is set, when you retrieve your authentication token normally, you'll also get a refresh token. When the normal token expires, you can request a new one similarly to the first token, replacing the code query parameter with the refresh_token parameter.

    To be clear, the process looks like this as per the docs:

    • Send your user to your web service
    • Direct them to the OneDrive authorise page with the correct parameters (make sure offline access is in the scope)
    • Wait for them to be redirected back to your app with the authorisation code
    • Exchange the authorisation code with OneDrive (using the oauth20_token.srf endpoint) to receive a set of tokens (one of these will be refresh)
    • Wait for the access_token you received to expire
    • Exchange the refresh_token you received for a new access token as per the "Getting a new access token or refresh token" section of the docs