Apps Developer Guide (Old)
  • Introduction
  • Create your first app in 4 easy steps
  • Overview
    • How does it work ?
    • Documentation
    • Deskpro Apps Tool
  • SDK
    • The Application Manifest
      • Manifest Reference
    • Storing data
      • Storing ticket data
    • Accessing the Deskpro REST API
    • Accessing remote services
    • The Application Installer
    • Application Contexts
      • ContextDataObject Reference
    • Events
  • Guides
    • Create an Oauth2 integration
    • Using an API Key to read data
  • Application Context
    • Get the authenticated user
    • Access Custom Fields
    • Interacting with the Host UI Container
  • Application Container
    • How do I badge my app icon
  • HTTP
    • How do I use a remote web service
  • OAuth2
    • How do I customize OAuth2 requests
  • UI Patterns
    • How do I split my app into different screens
Powered by GitBook
On this page
  • Passing extra parameters when requesting access
  • Passing extra parameters when refreshing access
  1. OAuth2

How do I customize OAuth2 requests

PreviousHow do I use a remote web serviceNextHow do I split my app into different screens

Last updated 6 years ago

Your OAuth2 provider may support non-standard parameters when initializing flows such as the authorization code flow or the token refresh flow. For example, uses the parameter access_type in the authorization code request to decide if it returns a refresh token alongside the regular access token.

In such cases you can do pass these extra parameters using the options argument present in all the methods of the class:

Passing extra parameters when requesting access

Access requests are handled via the authorization code flow. To add your parameters, add a query property:

// obtain a reference to the oauth client from the application client
const { oauth } = dpapp

// request a refresh token to be sent 
oauth.access('youtrack', { 
    query: { 'access_type' : 'offline' } 
}).then(resp => console.log(resp.refresh_token))

Passing extra parameters when refreshing access

If you want to refresh an access token, you must let Deskpro know what is the storage key which points to the refresh token you obtained from a previous step. Assuming that key is named access-tokens, your code might look like this:

// obtain a reference to the oauth client from the application client
const { oauth } = dpapp

// request a refresh token to be sent 
oauth.refresh('youtrack', { 
    query: { 'refresh_token' : 'access-tokens' } 
}).then(resp => console.log(resp.access_token))
Youtrack
OauthFacade