lib/nylas/resources/auth.rb in nylas-6.0.0.beta.2 vs lib/nylas/resources/auth.rb in nylas-6.0.0.beta.3

- old
+ new

@@ -14,19 +14,10 @@ # Auth class Auth < Resource include ApiOperations::Post include ApiOperations::Get - # Initializes Auth. - def initialize(sdk_instance) - super(sdk_instance) - - @grants = Grants.new(sdk_instance) - end - - attr_reader :grants - # Builds the URL for authenticating users to your application with OAuth 2.0. # # @param config [Hash] Configuration for building the URL. # @return [String] URL for hosted authentication. def url_for_oauth2(config) @@ -41,10 +32,21 @@ request[:grant_type] = "authorization_code" execute_token_request(request) end + # Create a Grant via Custom Authentication. + # + # @param request_body [Hash] The values to create the Grant with. + # @return [Array(Hash, String)] Created grant and API Request ID. + def custom_authentication(request_body) + post( + path: "#{api_uri}/v3/connect/custom", + request_body: request_body + ) + end + # Refreshes an access token. # # @param request [Hash] Code exchange request. # @return [Hash] Refreshed token object. def refresh_access_token(request) @@ -154,35 +156,20 @@ "client_id" => config[:client_id], "redirect_uri" => config[:redirect_uri], "access_type" => config[:access_type] || "online", "response_type" => "code" } - set_params(config) - - URI.encode_www_form(params) - end - - # Set the parameters for the query - def set_params(config) params["provider"] = config[:provider] if config[:provider] - set_config_params(config) - set_more_config(config) - end - - # Set login related configurations - def set_config_params(config) + params["prompt"] = config[:prompt] if config[:prompt] + params["metadata"] = config[:metadata] if config[:metadata] + params["state"] = config[:state] if config[:state] + params["scope"] = config[:scope].join(" ") if config[:scope] if config[:login_hint] params["login_hint"] = config[:login_hint] params["include_grant_scopes"] = config[:include_grant_scopes].to_s if config[:include_grant_scopes] end - params["scope"] = config[:scope].join(" ") if config[:scope] - end - # More config - def set_more_config(config) - params["prompt"] = config[:prompt] if config[:prompt] - params["metadata"] = config[:metadata] if config[:metadata] - params["state"] = config[:state] if config[:state] + URI.encode_www_form(params) end # Hashes the secret for PKCE authentication. # # @param secret [String] Randomly-generated authentication secret.