Class: Nylas::Auth
- Includes:
 - ApiOperations::Get, ApiOperations::Post
 
- Defined in:
 - lib/nylas/resources/auth.rb
 
Overview
Auth
Instance Method Summary collapse
- 
  
    
      #access_token_info(query_params: nil)  ⇒ Hash 
    
    
  
  
  
  
  
  
  
  
  
    
Get info about a specific token based on the identifier you include.
 - 
  
    
      #custom_authentication(request_body)  ⇒ Array(Hash, String) 
    
    
  
  
  
  
  
  
  
  
  
    
Create a Grant via Custom Authentication.
 - 
  
    
      #detect_provider(params)  ⇒ Array(Hash, String) 
    
    
  
  
  
  
  
  
  
  
  
    
Detects the provider of an email address.
 - 
  
    
      #exchange_code_for_token(request)  ⇒ Hash 
    
    
  
  
  
  
  
  
  
  
  
    
Exchanges an authorization code for an access token.
 - 
  
    
      #refresh_access_token(request)  ⇒ Hash 
    
    
  
  
  
  
  
  
  
  
  
    
Refreshes an access token.
 - 
  
    
      #revoke(token)  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    
Revokes a single access token.
 - 
  
    
      #url_for_admin_consent(config)  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    
Builds the URL for admin consent authentication for Microsoft.
 - 
  
    
      #url_for_oauth2(config)  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    
Builds the URL for authenticating users to your application with OAuth 2.0.
 - 
  
    
      #url_for_oauth2_pkce(config)  ⇒ Hash 
    
    
  
  
  
  
  
  
  
  
  
    
Builds the URL for authenticating users to your application with OAuth 2.0 and PKCE.
 
Methods inherited from Resource
Constructor Details
This class inherits a constructor from Nylas::Resource
Instance Method Details
#access_token_info(query_params: nil) ⇒ Hash
Get info about a specific token based on the identifier you include. Use either the ID Token or Access Token.
      24 25 26 27 28 29  | 
    
      # File 'lib/nylas/resources/auth.rb', line 24 def access_token_info(query_params: nil) get( path: "#{api_uri}/v3/connect/tokeninfo", query_params: query_params ) end  | 
  
#custom_authentication(request_body) ⇒ Array(Hash, String)
Create a Grant via Custom Authentication.
      53 54 55 56 57 58  | 
    
      # File 'lib/nylas/resources/auth.rb', line 53 def custom_authentication(request_body) post( path: "#{api_uri}/v3/connect/custom", request_body: request_body ) end  | 
  
#detect_provider(params) ⇒ Array(Hash, String)
Detects the provider of an email address.
      118 119 120 121 122 123  | 
    
      # File 'lib/nylas/resources/auth.rb', line 118 def detect_provider(params) post( path: "#{api_uri}/v3/providers/detect", query_params: params ) end  | 
  
#exchange_code_for_token(request) ⇒ Hash
Exchanges an authorization code for an access token.
      43 44 45 46 47  | 
    
      # File 'lib/nylas/resources/auth.rb', line 43 def exchange_code_for_token(request) request[:grant_type] = "authorization_code" execute_token_request(request) end  | 
  
#refresh_access_token(request) ⇒ Hash
Refreshes an access token.
      64 65 66 67 68  | 
    
      # File 'lib/nylas/resources/auth.rb', line 64 def refresh_access_token(request) request[:grant_type] = "refresh_token" execute_token_request(request) end  | 
  
#revoke(token) ⇒ Boolean
Revokes a single access token.
      105 106 107 108 109 110 111 112 113  | 
    
      # File 'lib/nylas/resources/auth.rb', line 105 def revoke(token) post( path: "#{api_uri}/v3/connect/revoke", query_params: { token: token } ) true end  | 
  
#url_for_admin_consent(config) ⇒ String
Builds the URL for admin consent authentication for Microsoft.
      93 94 95 96 97 98 99  | 
    
      # File 'lib/nylas/resources/auth.rb', line 93 def (config) config_with_provider = config.merge("provider" => "microsoft") url = url_auth_builder(config_with_provider) url.query = (config) url.to_s end  | 
  
#url_for_oauth2(config) ⇒ String
Builds the URL for authenticating users to your application with OAuth 2.0.
      35 36 37  | 
    
      # File 'lib/nylas/resources/auth.rb', line 35 def url_for_oauth2(config) url_auth_builder(config).to_s end  | 
  
#url_for_oauth2_pkce(config) ⇒ Hash
Builds the URL for authenticating users to your application with OAuth 2.0 and PKCE.
IMPORTANT: You must store the 'secret' returned to use it inside the CodeExchange flow.
  
      75 76 77 78 79 80 81 82 83 84 85 86 87  | 
    
      # File 'lib/nylas/resources/auth.rb', line 75 def url_for_oauth2_pkce(config) url = url_auth_builder(config) # Generates a secret and hashes it. secret = SecureRandom.uuid secret_hash = hash_pkce_secret(secret) # Adds code challenge to URL generation. url.query = build_query_with_pkce(config, secret_hash) # Returns the URL with secret and hashed secret. { secret: secret, secret_hash: secret_hash, url: url.to_s } end  |