module Pinterest::Endpoints::Authentication
Authentication
related endpoints.
Public Instance Methods
fetch_access_token(authorization_token)
click to toggle source
Fetches the access token.
@param [String] authorization_token The authorization token. @return [String] The authentication token.
# File lib/pinterest/endpoints/authentication.rb, line 44 def fetch_access_token(authorization_token) ensure_param(client_id, "You must specify the client_id.") ensure_param(client_secret, "You must specify the client_secret.") ensure_param(authorization_token, "You must specify the authorization_token.") # Create parameters query = cleanup_params({ client_id: client_id, client_secret: client_secret, grant_type: "authorization_code", code: authorization_token }) # Perform the request and then get the token response = perform_network_request(method: :post, url: versioned_url("/oauth/token"), query: query) @access_token = response.body["access_token"] end
verify_access_token()
click to toggle source
Verifies the access token.
@return [Hash] The access token informations.
# File lib/pinterest/endpoints/authentication.rb, line 63 def verify_access_token ensure_param(client_id, "You must specify the client_id.") ensure_param(access_token, "You must set the access token first.") # Get the data data = perform_network_request(url: versioned_url("/oauth/inspect"), authenticated: true).body["data"] # Prepare for output create_authentication(data) end