Search code examples
javarestlogiconedrive

How to get access token for one drive API to upload a file?


I am creating an application where I want to call API of OneDrive to upload file. Here is the link to page and API I am using is : https://apis.live.net/v5.0/me/skydrive/files/HelloWorld.txt?access_token=ACCESS_TOKEN

I have followed all steps from "code flow" as per link here and got the access token as in response, but it say's 'invalid access token' after using it while running the same API. Here is screenshot of what I tried. I am confused which token to use in that API. Where I can get that ACCESS_TOKEN to run 'upload file' API successfully ?


Solution

  • Problem solved. While running following API , we should add onedrive.readwrite in the scope to upload the file through API.

    Here are the steps to follow to create access token from 'code flow'.

    https://login.live.com/oauth20_authorize.srf?client_id={client_id}&scope={scope}&response_type=code&redirect_uri={uri}