How To Use Onedrive App On Macnewpb



Onedrive

How to Use OneDrive for the Mac. Microsoft OneDrive is a cloud-based storage and syncing solution that works on Mac, PC, and mobile devices with access to the internet. When you install OneDrive on your Mac, it appears to be just another folder. Aug 19, 2020 How to set up OneDrive on Windows 10. Search OneDrive and click the top result to open the app. Confirm your Microsoft account address. Click the Sign in button. Confirm your account password. Click the Sign in button. (Optional) Click the Change location option if you want to specify a. Aug 15, 2018 OneDrive tips and tricks: How to master Microsoft's free cloud storage. If you haven't checked out OneDrive lately, you're missing out. Over the past two years, Microsoft has methodically added a.

-->

To use the OneDrive API via Microsoft Graph, you need to have an access token that authorizes your app with a particular set of permissions for a user.In this section, you'll learn how to:

  1. Register your application to get an application ID.
  2. Sign your user in with the specified scopes using the token flow or code flow.
  3. Sign the user out (optional).

The OneDrive API uses the standard OAuth 2.0 authorization framework to authorize apps and generate access tokens.You must provide an access token for every authenticated API call by using an HTTP header:

Note: The recommended authorization framework is using the Azure AD v2.0 endpoint.However, some enterprise scenarios may require using the original Azure AD endpoint.For more information see App authentication with Microsoft Graph.

Register your app

The first step is to register an app with Microsoft and provide some details about your app.You can register your application and receive a new app ID from the Azure App registrations page.

For detailed steps on how to register your application, see registering your app for OneDrive API.

Sign users in

Your app must initiate the sign-in process by contacting the Azure Active Directory authorization endpoint with a specified scope.The flow follows standard OAuth 2.0 authorization flows and requires calls from a web browser or web-browser control.The result of the authorization flow will return an access token and optionally other tokens which your app can use to access the API.

Authentication scopes

Scopes determine what type of access the app is granted when the user is signed in.All scopes support single sign-on on the web, which means that if a user is already signed in to OneDrive, then the user can skip the authentication flow and go straight to the authorization flow.

Scope nameDescription
offline_accessEnables your app to work offline even when the user isn't active. Requires the use of code-flow.
files.readGrants read-only permission to all of a user's OneDrive files.
files.read.allGrants read-only permission to all of a user's OneDrive files, including files shared with the user.
files.readwriteGrants read and write permission to all of a user's OneDrive files.
files.readwrite.allGrants read and write permission to all of a user's OneDrive files, including files shared with the user.

As an example, a typical application might request the following scopes:

Supported Authentication flows

While Azure Active Directory supports multiple authorization flows, the most common two are outlined here:

Token flow

The most straightforward authorization flow is the token flow.This flow is useful for quickly obtaining an access token to use the OneDrive API in an interactive fashion.This flow does not provide a refresh token, and therefore is not a good fit for longterm access to resources.

To start the sign-in process with the token flow, use a web browser or web-browser control to load a URL request.

Required query string parameters

Parameter nameValueDescription
client_idstringThe client ID value created for your application.
redirect_uristringThe redirect URL that the browser is sent to when authentication is complete.
response_typestringThe type of response expected from the authorization flow. For this flow, the value must be token.
scopestringA space-separated list of scopes your application requires.

Response

Upon successful authentication and authorization of your application, the web browser is redirected to the redirect URL provided with additional parameters added to the URL.

Values for access_token, authentication_token, and user_id are truncatedin the previous example. The values for access_token and authentication_tokenare quite long.

How To Use Onedrive App On Macnewpb Computer

You can use the value of access_token to make requests to the Microsoft Graph.

Code flow

Download Onedrive App Windows 10

The code flow for authentication is a three-step process with separate calls to authenticate and authorize the application and to generate an access token to use the OneDrive API.This also allows your application to receive a refresh token that will enable long-term use of the API in some scenarios, to allow access when the user isn't actively using your application.

Step 1. Get an authorization code

How To Use Onedrive App On Macnewpb

To start the sign-in process with the code flow, use a web browser or web-browser control to load this URL request.

Required query string parameters

Parameter nameValueDescription
client_idstringThe client ID created for your app.
scopestringA space-separated list of scopes that your app requires.
redirect_uristringThe redirect URL that the browser is sent to when authentication is complete.
response_typestringThe type of response expected from the authorization flow. For this flow, the value must be code.

Response

Upon successful authentication and authorization of your application, the web browser will be redirected to your redirect URL with additional parameters added to the URL.

Step 2. Redeem the code for access tokens

After you have received the code value, you can redeem this code for a set of tokens that allow you to authenticate with the OneDrive API.To redeem the code, make the following request:

Required request body parameters

The request body is a properly encoded URL string, with some required parameters.

Parameter nameValueDescription
client_idstringThe client ID value created for your application.
redirect_uristringThe redirect URL that the browser is sent to when authentication is complete. This should match the redirect_uri in the first request.
client_secretstringThe client secret created for your application.
codestringThe authorization code you received in the first authentication request.

Note For web apps, the domain portion of the redirect URI must match the domain portion of the redirect URI that you specified in the Microsoft Developer Center.

Response

If the call is successful, the response for the POST request contains a JSON string that includes several properties, including access_token, token_type, and refresh_token (if you requested the wl.offline_access scope).

You can now store and use the access_token provided to make authenticated requests to Microsoft Graph.

Download onedrive app windows 10

Important: Treat the values of access_token and refresh_token in this response as securely as you would a user's password.

The access token is valid for only the number of seconds that is specified in the expires_in property.You can request a new access token by using the refresh token (if available), or by repeating the authentication request from the beginning.

Step 3. Get a new access token or refresh token

Use

If your app has requested the offline_access scope this step will return a refresh_token that can be used to generate additional access tokens after the initial token has expired.

To redeem the refresh token for a new access token, make the following request:

Required request body parameters

The request body is a properly encoded URL string, with some required parameters.

Parameter nameValueDescription
client_idstringThe client ID created for your application.
redirect_uristringThe redirect URL that the browser is sent to when authentication is complete. This should match the redirect_uri value used in the first request.
client_secretstringThe client secret created for your application.
refresh_tokenstringThe refresh token you received previously.

Note For web apps, the domain portion of the redirect URI must match the domain portion of the redirect URI that you specified in the Microsoft Developer Center.

Response

If the call is successful, the response for the POST request contains a JSON string that includes several properties including access_token, authentication_token and refresh_token if you requested the offline_access scope.

You can now store and use the access_token to make authenticated requests to Microsoft Graph.

Important: Treat the values of access_token and refresh_token in this response as securely as you would a user's password.

The access token is valid for only the number of seconds that is specified in the expires_in property.You can request a new access token by using the refresh token (if available) or by repeating the authentication request from the beginning.

Sign the user out

To sign a user out, perform the following steps:

  1. Delete any cached access_token or refresh_token values you've previously received from the OAuth flow.
  2. Perform any sign out actions in your application (for example, cleaning up local state, removing any cached items, etc.).
  3. Make a call to the authorization web service using this URL:

This call will remove any cookies that enable single sign-on to occur and ensure that next time your app launches the authorization flow, the user will be required to sign in again.Using this logout flow does not revoke any content previously granted to an applicaiton.

Macbook

Required query string parameters

Onedrive App Windows 10

Parameter nameValueDescription
redirect_uristringThe redirect URL that the browser is sent to when authentication is complete. This must match exactly the redirect_uri value used in the get token request.

After removing the cookie, the browser will be redirected to the redirect URL you provided.When the browser loads your redirect page, no authentication query string parameters will be set, and you can infer the user has been logged out.

Revoking Access

Microsoft account users can revoke an app's access to their account by visiting the Microsoft account manage consent page.

When consent for an app is revoked, any refresh token previously provided to your application will no longer be valid.You will need to repeat the authentication flow to request a new access and refresh token from scratch.

Related topics

How To Use Onedrive App On Macnewpb Windows 10

The following topics contain high-level overviews of other concepts that apply to the OneDrive API.