Get 3-legged Token with Implicit Grant
If you need an end user to authorize your app to act on the user’s behalf, you may want to check out this tutorial.
The implicit grant type is used to obtain access tokens and is optimized for public clients known to operate a particular redirection URI. These clients are typically implemented in a browser using a scripting language such as JavaScript
The main difference here from the authorization code grant type is that the client receives the access token as the result of the authorization request. The refresh token is not issued in this case which requires repeating the authorization process once the access token expires.
Based on the use case that needs to be covered by your application and the above described constraints, you should make a choice between the authorization code and implicit grant type workflow.
Note that this tutorial does not show you how to write your code, instead it just illustrates the calls you need to instrument in your code.
Before You Begin
Before you begin, please follow the Create an App tutorial to create your app on APS. Specify your app’s callback URL and note your client ID and secret.
Familiarize yourself with the overall flow:

Step 2: Implement Code that Extracts the Access Token
In this example, the user was redirected to
http://sampleapp.com/oauth/callback#access_token=eyJhbGciOiJIUzI1NiIsImtpZCI6Imp3dF9zeW1tZXRyaWNfa2V5In0.eyJ1c2VyaWQiOiJIU0pHTTdUSFJIVUIiLCJleHAiOjE1MDE4OTI5MjgsInNjb3BlIjpbXSwiY2xpZW50X2lkIjoibk9oYnJPZW9HeHE4R2JBeFVvR2NIcXpEWmVqQWxxSUsiLCJhdWQiOiJodHRwczovL2F1dG9kZXNrLmNvbS9hdWQvand0ZXhwMTQ0MCIsImp0aSI6Im12bmwyZ2tKOEU4Tkd2S2JEVk00S3BHaTRCYkZtRndyUmVrd2NjT3B3RU1OTlVTdnZrNnljNllWSGo3d29WWjMifQ.Niy8dwBQVuhcaCTClZqttJleuKIoQtnS8yoT1ZJWgNg&token_type=Bearer&expires_in=86399
.
- Your code that serves up the
/oauth/callback
URL in your web app should return a web page with a snippet of JavaScript to extract the fragment access_token=eyJhbGciOiJIUzI1NiIsImtpZ...&token_type=Bearer&expires_in=86399
from the URL and post the values to your server for parsing.
<html>
<body>
<script>
var params = {},
queryString = location.hash.substring(1),
regex = /([^&=]+)=([^&]*)/g,
m;
while (m = regex.exec(queryString)) {
params[m[1]] = m[2];
}
alert("your access token is : " + params["access_token"]);
</script>
</body>
</html>
You will then be able to use the access token to make calls to other API endpoints on behalf of the end user
that require the data:read
scope and have a “user context required” or “user context optional” authentication context.
After the token expires, You should repeat this flow to authorize the user again to acquire a new access token.