Module: Asana::Authentication::OAuth2
- Defined in:
- lib/asana/authentication/oauth2.rb,
lib/asana/authentication/oauth2/client.rb,
lib/asana/authentication/oauth2/access_token_authentication.rb,
lib/asana/authentication/oauth2/bearer_token_authentication.rb
Overview
Deals with OAuth2 authentication. Contains a function to get an access token throught a browserless authentication flow, needed for some applications such as CLI applications.
Defined Under Namespace
Classes: AccessTokenAuthentication, BearerTokenAuthentication, Client
Class Method Summary collapse
-
.offline_flow(client_id: required('client_id'), client_secret: required('client_secret')) ⇒ Object
Retrieves an access token through an offline authentication flow.
Class Method Details
.offline_flow(client_id: required('client_id'), client_secret: required('client_secret')) ⇒ Object
Note:
This function reads from STDIN and writes to STDOUT. It is meant to be used only within the context of a CLI application.
Retrieves an access token through an offline authentication flow. If your application can receive HTTP requests, you might want to opt for a browser-based flow and use the omniauth-asana gem instead.
Your registered application’s redirect_uri should be exactly “urn:ietf:wg:oauth:2.0:oob”.
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/asana/authentication/oauth2.rb', line 29 def offline_flow(client_id: required('client_id'), client_secret: required('client_secret')) client = Client.new(client_id: client_id, client_secret: client_secret, redirect_uri: 'urn:ietf:wg:oauth:2.0:oob') STDOUT.puts '1. Go to the following URL to authorize the ' \ " application: #{client.}" STDOUT.puts '2. Paste the authorization code here: ' auth_code = STDIN.gets.chomp client.token_from_auth_code(auth_code) end |