OAuth2TokenFromResourceOwner(Client_ID: String, ClientSecret: String, Scope: String, TokenEndPoint: String, UserName: String, Password: String [, Options: StringList]): Object
OAuth2TokenFromResourceOwner returns a JSON OAuth2 token based on the parameters passed. If an error occurs, the returned JSON contains error, responsecode and errorcode properties instead of a token.
OAuth2TokenFromResourceOwner function syntax has these named arguments:
Parameter |
Description |
|---|---|
Client_ID |
Required. The OAuth2 client identifier. |
Client Secret |
Required. The client secret string. |
Scope |
Required. The scope of the authorisation. |
Token End Point |
Required. Web address of the token end point. |
User Name |
Required. User Name of the resource owner. |
Password |
Required. Password for the resource owner. |
Options |
Optional. A StringList of name/value pairs that are appended to the token request as additional form parameters. Use this to supply extras the token endpoint requires — for example, an otpcode for providers (such as the Accredo Web Service) that enforce two-factor authentication on the resource owner grant. |
Example — passing an OTP code
Dim opts As Object
opts = NewStringList
opts.Add("otpcode=123456")
Dim token As Object
token = OAuth2TokenFromResourceOwner( _
"my-client-id", _
"my-client-secret", _
"accredo.api", _
"https://example.accredo.co.nz/oauth2/token", _
"alice", _
"p@ssw0rd", _
opts)
If token.error <> "" Then
Message "Token request failed (" & token.responsecode & "/" & token.errorcode & "): " & token.error
End If