atlassian-connect-core-0.8.0.0: Atlassian Connect snaplet for the Snap Framework and helper code.

Copyright(c) Robert Massioli 2017
LicenseAPACHE-2
Maintainerrmassaioli@atlassian.com
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Snap.AtlassianConnect.OAuth

Description

By default, all HTTP requests that your add-on makes to an Atlassian application (like JIRA or Confluence) will be performed as your add-on user. For example, if your add-on service makes a HTTP request to comment on a JIRA issue then the comment will be made as your add-on. However, if your addon requests the ACT_AS_USER scope then is is capable of using the OAuth service to generate an "access token" for a particular user on a tenant. This access token can be used to make make HTTP requests from your add-on service to an Atlassian product as a user inside that product. This allows you to make HTTP requests that can impersonate users on a given instance.

Using our previous example, if you generated an access token for the user Bob and then made the same request, but with that new access token, then the comment made on the issue would appear to come from Bob.

You can read more about access token on the official documentation.

Synopsis

Documentation

requestAccessToken Source #

Arguments

:: Tenant

The tenant to generate the Access Token for.

-> UserKey

The user key of the user on the tenant that should be impersonated.

-> Maybe [ProductScope]

The collection of scopes that will be used for impersonation. Providing none requests all scopes that the add-on provides.

-> IO (Either ProductErrorResponse (Maybe AccessTokenResponse))

Returns either a HTTP error or the result of attempting to parse the AccessTokenResponse.

Request an access token for a tenant and user with the requested scopes.

This token will allow you to post subsequent HTTP requests using the Snap.AtlassianConnect.HostRequest module as an impersonated user.

The access token that is returned should be reused as much as possible in order to avoid hitting rate limits from the token generation service. Each token is specific to the tenant, user and scopes that it was created for. This means that the token reuse must be tenant, user and scopes specific.

data AccessTokenResponse Source #

This represents the response that an OAuth Access token request should expect to recieve from auth.atlassian.io.

Constructors

AccessTokenResponse 

Fields

data AccessToken Source #

An access token that can be used in subsequent requests.