App Authentication with OAuth2

This documentation describes the how to get your app authenticated with CloudApps via OAuth2.


Quick start

If you are already familiar with OAuth2 and the use of Authorization Code Grant, here is the quick list of required information.

KeyValue
Authorize endpointhttps://api.cloudprinter.com/cloudauth/1.0/oauth2/authorize
Access Token endpointhttps://api.cloudprinter.com/cloudauth/1.0/oauth2/token
ScopeSet to "read" or "read-write" depending on the access level needed
Client idFrom app registration - Read more
Client secretFrom app registration - Read more

If you still need more information, then read the next sections.


Authentication flow overview

Here is a quick overview of the authentication flow for OAuth2 authentication with CloudApps for Connected Apps:

  1. Authorization code: Call the authorize endpoint. Here the end user will be requested to login and grant your app access to Cloudprinter.com resources.

  2. Access Token: With the Authorization Code call the Access Token exchange endpoint. Once validated the we return an Access Token and a Refresh Token.

  3. On each request to the CloudApps API the Access Token must be included.

Authentication flow details

Now lets go more in details on each step and go through the information your app need to include in each call to the Cloudprinter.com Cloudauth and CloudApps API's


Step 1 - Authorization Code

To get the Authorization Code call the authorize endpoint. Here the end user will be requested to login and grant your app access to Cloudprinter.com resources.

Endpoint: https://api.cloudprinter.com/cloudauth/1.0/oauth2/authorize

In this call you include the following parameters:

KeyValue
client_idThe client id given at app registration
redirect_uriYour apps redirect URL, will be matched against the redirect URL given at app registration
stateYour reference, which will be included unchanged on the redirect URL
scopeSet to "read" or "read-write" depending on the access level needed
response_type"code"


Step 2 - Access Token

When you have an Authorization Code you exchange it to an Access Code by posting to the token endpoint. This will return the Access token you include as a Bearer token in the header of all calls to the CloudApps API. Make sure that you use Content-Type: application/x-www-form-urlencoded in header of request.

Endpoint: https://api.cloudprinter.com/cloudauth/1.0/oauth2/token


In this call you include the following parameters:

KeyValue
codeThe authorization code created in step 1
client_idThe client id given at app registration
client_secretThe client secret given at app registration
redirect_uriYour apps redirect URL, will be matched against the redirect URL given at app registration
grant_type"authorization_code"

Step 3 - Call the API

Now you have been Authenticated and can start using the CloudApps API.

You include the Access Token in the header of all calls to the CloudApps API as a Bearer token.

KeyValue
AuthorizationBearer access token, e.g.
"Bearer e09d52fd0e3def4a5c32d58e056795dbfaff34a1"