-
Notifications
You must be signed in to change notification settings - Fork 69
[Update] Oauth section update #192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
8ab303f
initial commit
db2da72
updated oauth section
f068e68
applied changes requested by wsmith
39d2309
Copy edit OAuth section
nmelehan 4cc5ae5
added some clarification to private/public steps
5a8e288
Add references to RFC6749 in OAuth Workflow section
nmelehan 8801aed
added sentence with reference to authorization code flow and implicit…
243303c
Merge branch 'oauth-docs-refresh' of github.com:hzoppetti/linode-api-…
75586b7
moved workflow note closer to actual workflow area
650d8b3
Copy edit OAuth section
nmelehan 45146ad
Merge branch 'oauth-docs-refresh' of https://github.com/hzoppetti/lin…
nmelehan 8f1b0cf
Make notes in OAuth Workflow section into bulleted list
nmelehan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,33 +47,45 @@ info: | |
| **HTTP Authorization Scheme** | bearer | | ||
|
||
## OAuth | ||
If all you need is a Personal Access Token, feel free to skip ahead to the next section. | ||
|
||
The OAuth workflow is a three-step process to authenticate a User before an | ||
application can start making API calls on the User's behalf. If all you need | ||
is a Personal Access Token, feel free to skip ahead to the next section. | ||
For more help on OAuth see our guide on [How to Create an OAuth App with teh Linode Python API Library](https://www.linode.com/docs/platform/api/how-to-create-an-oauth-app-with-the-linode-python-api-library/#oauth-2-authentication-exchange). | ||
|
||
First, the User visits the application's website and is directed to log with | ||
Linode. The User is then redirected to Linode's authentication server and | ||
presented the scope levels the application is requesting. Once the User | ||
accepts the request for access, we redirect them back to the application's | ||
specified redirect URI with an access code. | ||
Before you begin, you need to [Create an OAuth Client](https://developers.linode.com/api/v4/account-oauth-clients/#post). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might also consider https://cloud.linode.com/profile/clients There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed to include both options |
||
|
||
Once the User has logged in to Linode and you have received an exchange code, | ||
you will need to exchange that access code for an Authorization token. You | ||
do this by making an HTTP POST request to the following address: | ||
- For this you will pass a `label` and a `redirect_uri`. | ||
- The return from this endpoint will give you a `client_id` and a `secret`. | ||
- You can choose to make this `public`. The workflow below is split for public and private paths where they diverge. | ||
|
||
``` | ||
https://login.linode.com/oauth/token | ||
``` | ||
The OAuth workflow is a series of exchanges between your third-party app and Linode used | ||
to authenticate a User before an application can start making API calls on the User's behalf. | ||
|
||
| PRIVATE WORKFLOW | PUBLIC WORKFLOW | | ||
|------------------|-----------------| | ||
| 1. The User visits the application's website and is directed to login with Linode. | 1. The User visits the application's website and is directed to login with Linode. | | ||
| 2. Your application then redirects the user to Linode's [authentication server](https://login.linode.com) with the client application's `client_id` and requested OAuth `scope`, which appear in the URL of the login page. | 2. Your application then redirects the user to Linode's [authentication server](https://login.linode.com) with the client application's `client_id` and requested OAuth `scope`, which appear in the URL of the login page. | | ||
| 3. The user logs into the authorization server with their username and password. | 3. The user logs into the authorization server with their username and password. | | ||
| 4. The authorization server redirects the user to the specificed redirect URL with a temporary authorization `code` (exchange code) in the URL. | 4. The authorization server redirects the user back to your applaction with an OAuth token in the URL hash. This is temporary and expires in 2 hours without a `refresh_token`. | | ||
| 5. The application issues a POST request (*see below*) to the authentication server with the exchange code, `client_id`, and the client application's `client_secret`. In return, the server returns an OAuth token and `refresh_token`. | | | ||
| 6. The authentication server responds to the client application with a new OAuth `access_token`. `access_token` is set to expire in 2 hours if not refreshed. | | | ||
hzoppetti marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 7. The refresh token can be used to get a new OAuth `access_token` for another 2 hours by contacting the authentication server again with the `client_id`, `client_secret`, and `refresh_token`. | | | ||
hzoppetti marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Once the User has logged into Linode and you have received an exchange code, | ||
hzoppetti marked this conversation as resolved.
Show resolved
Hide resolved
|
||
you will need to trade that exchange code for an Authorization token. You | ||
do this by making an HTTP POST request to the following address: | ||
|
||
``` | ||
https://login.linode.com/oauth/token | ||
``` | ||
|
||
Make this request as `application/x-www-form-urlencoded` or as | ||
`multipart/form-data` and include the following parameters in the POST body: | ||
Make this request as `application/x-www-form-urlencoded` or as | ||
`multipart/form-data` and include the following parameters in the POST body: | ||
|
||
| PARAMETER | DESCRIPTION | | ||
|-----------|-------------| | ||
| client_id | Your app's client ID | | ||
| client_secret | Your app's client secret | | ||
| code | The code you just received from the redirect | | ||
| PARAMETER | DESCRIPTION | FIND OR UPDATE THIS INFORMATION | | ||
|-----------|-------------|---------------------------------| | ||
| client_id | Your app's client ID. | [List your OAuth Clients](https://developers.linode.com/api/v4/account-oauth-clients). | | ||
| client_secret | Your app's client secret. | [View your OAuth Client](https://developers.linode.com/api/v4/account-oauth-clients-client-id). [Reset Your OAuth Client Secret](https://developers.linode.com/api/v4/account-oauth-clients-client-id-reset-secret/#post). | | ||
| code | The code you just received from the redirect | [View your OAuth Client](https://developers.linode.com/api/v4/account-oauth-clients-client-id). [Reset Your OAuth Client Secret](https://developers.linode.com/api/v4/account-oauth-clients-client-id-reset-secret/#post). | | ||
hzoppetti marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
You'll get a reponse like this: | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.