Class: Twilio::REST::Oauth::V2::TokenList

Inherits:
ListResource show all
Defined in:
lib/twilio-ruby/rest/oauth/v2/token.rb

Instance Method Summary collapse

Constructor Details

#initialize(version) ⇒ TokenList

Initialize the TokenList

Parameters:

  • version (Version)

    Version that contains the resource



26
27
28
29
30
31
32
33
# File 'lib/twilio-ruby/rest/oauth/v2/token.rb', line 26

def initialize(version)
    super(version)
    
    # Path Solution
    @solution = {  }
    @uri = "/token"
    
end

Instance Method Details

#create(account_sid: :unset, grant_type: :unset, client_id: :unset, client_secret: :unset, code: :unset, redirect_uri: :unset, audience: :unset, refresh_token: :unset, scope: :unset, code_verifier: :unset) ⇒ TokenInstance

Create the TokenInstance

Parameters:

  • account_sid (String) (defaults to: :unset)

    Optional Account SID to perform on behalf of requests.

  • grant_type (String) (defaults to: :unset)

    Grant type is a credential representing resource owner's authorization which can be used by client to obtain access token.

  • client_id (String) (defaults to: :unset)

    A 34 character string that uniquely identifies this OAuth App.

  • client_secret (String) (defaults to: :unset)

    The credential for confidential OAuth App.

  • code (String) (defaults to: :unset)

    JWT token related to the authorization code grant type.

  • redirect_uri (String) (defaults to: :unset)

    The redirect uri

  • audience (String) (defaults to: :unset)

    The targeted audience uri

  • refresh_token (String) (defaults to: :unset)

    JWT token related to refresh access token.

  • scope (String) (defaults to: :unset)

    The scope of token

  • code_verifier (String) (defaults to: :unset)

    The PKCE code verifier used to generate the code_challenge in the authorization request.

Returns:



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/twilio-ruby/rest/oauth/v2/token.rb', line 47

def create(
  account_sid: :unset, 
  grant_type: :unset, 
  client_id: :unset, 
  client_secret: :unset, 
  code: :unset, 
  redirect_uri: :unset, 
  audience: :unset, 
  refresh_token: :unset, 
  scope: :unset, 
  code_verifier: :unset
)

    params = Twilio::Values.of({
        'account_sid' => ,
    })
    data = Twilio::Values.of({
        'grant_type' => grant_type,
        'client_id' => client_id,
        'client_secret' => client_secret,
        'code' => code,
        'redirect_uri' => redirect_uri,
        'audience' => audience,
        'refresh_token' => refresh_token,
        'scope' => scope,
        'code_verifier' => code_verifier,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.create('POST', @uri, params: params, data: data, headers: headers)
    TokenInstance.new(
        @version,
        payload,
    )
end

#create_with_metadata(account_sid: :unset, grant_type: :unset, client_id: :unset, client_secret: :unset, code: :unset, redirect_uri: :unset, audience: :unset, refresh_token: :unset, scope: :unset, code_verifier: :unset) ⇒ TokenInstance

Create the TokenInstanceMetadata

Parameters:

  • account_sid (String) (defaults to: :unset)

    Optional Account SID to perform on behalf of requests.

  • grant_type (String) (defaults to: :unset)

    Grant type is a credential representing resource owner's authorization which can be used by client to obtain access token.

  • client_id (String) (defaults to: :unset)

    A 34 character string that uniquely identifies this OAuth App.

  • client_secret (String) (defaults to: :unset)

    The credential for confidential OAuth App.

  • code (String) (defaults to: :unset)

    JWT token related to the authorization code grant type.

  • redirect_uri (String) (defaults to: :unset)

    The redirect uri

  • audience (String) (defaults to: :unset)

    The targeted audience uri

  • refresh_token (String) (defaults to: :unset)

    JWT token related to refresh access token.

  • scope (String) (defaults to: :unset)

    The scope of token

  • code_verifier (String) (defaults to: :unset)

    The PKCE code verifier used to generate the code_challenge in the authorization request.

Returns:



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/twilio-ruby/rest/oauth/v2/token.rb', line 101

def (
  account_sid: :unset, 
  grant_type: :unset, 
  client_id: :unset, 
  client_secret: :unset, 
  code: :unset, 
  redirect_uri: :unset, 
  audience: :unset, 
  refresh_token: :unset, 
  scope: :unset, 
  code_verifier: :unset
)

    params = Twilio::Values.of({
        'account_sid' => ,
    })
    data = Twilio::Values.of({
        'grant_type' => grant_type,
        'client_id' => client_id,
        'client_secret' => client_secret,
        'code' => code,
        'redirect_uri' => redirect_uri,
        'audience' => audience,
        'refresh_token' => refresh_token,
        'scope' => scope,
        'code_verifier' => code_verifier,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('POST', @uri, params: params, data: data, headers: headers)
    token_instance = TokenInstance.new(
        @version,
        response.body,
    )
    TokenInstanceMetadata.new(
        @version,
        token_instance,
        response.headers,
        response.status_code
    )
end

#to_sObject

Provide a user friendly representation



152
153
154
# File 'lib/twilio-ruby/rest/oauth/v2/token.rb', line 152

def to_s
    '#<Twilio.Oauth.V2.TokenList>'
end