User Tools

Site Tools


dev:app_authentication_example

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Last revisionBoth sides next revision
dev:app_authentication_example [2016/04/21 17:04] sudev:app_authentication_example [2016/04/21 17:13] – [3. Authenticated Requests] su
Line 99: Line 99:
 ==== 3. Authenticated Requests ==== ==== 3. Authenticated Requests ====
  
-Now that you have an access token, you can make requests to the App Store API. You can make an API request using cURL as follows:+Now that you have an access token, you can make requests to the App Store API. 
 + 
 +=== 3.1 Access Tokens === 
 + 
 +When an application logs a user in via an OAuth service, they receive an access token for the user, also known as a bearer token, as well as information about when the access token expires, and (possibly) a refresh token that can be used to retrieve a new access token when the old one expires, instead of requiring the user to explicitly log into the application again. 
 + 
 +The token contains embedded information about the user, and is signed and encrypted by the OAuth service so that only the machine that issued the token can authenticate requests made using the token.  When an HTTP request is authenticated using a bearer token, a `ClaimsIdentity` object is assigned to the OWIN request object that contains all of the claims that were embedded in the token. 
 + 
 +To authenticate requests made to the App Store API, the calling application must include a valid access token in the HTTP headers of the request.  The token is specified using the `Authorization` HTTP request header, using the `Bearer` authentication scheme.  For example: 
  
 <code> <code>
  
-curl -H "Authorization: Bearer RsT5OjbzRn430zqMLgV3Ia"+var request = new HttpRequestMessage(HttpMethod.Get, "https://appstore.intelligentplant.com/api/resource/getuserinfo"); 
-https://appstore.intelligentplant.com/api/Resource/GetUserInfo+request.Authorization = new AuthenticationHeaderValue("Bearer", "my_access_token"); 
 + 
 +var response = await httpClient.SendAsync(request, someCancellationToken).ConfigureAwait(false); 
 +...
  
 </code> </code>
  
        
dev/app_authentication_example.txt · Last modified: 2017/11/21 16:46 by su