Please enable JavaScript to view this site.

A-Shell Reference

Updated May 2024; see History

xcall OAUTH2, opcode, status, clientid$, clientsecret$, option, auth'endpoint$, token'endpoint$, challenge$, scope$, refresh'token$, response$, handle, stsmsg$ {,file {,add'param}}

OAUTH2 implements the industry-standard OAUTH2 protocol for authorization via the ASHNET library update 1.12.163. It provides a means of obtaining an OAUTH2 access token needed for some modern web services, such as Gmail when "less secure applications" is not enabled.

Parameters

 

Name

Type

I/O

Description

opcode

Num

in

1: Request the auth url

2: Request the token after signing in on web

3: Request a refresh token for previously authorized service

status

Signed Int

out

Return status: 0=ok, else ASHNET Status Codes

clientid$

String

in

Client id previously assigned by service provider

clientsecret$

String

in

Client secret previously assigned (or negotiated) by service provider

option  

 

in

For opcode 1, port; for opcode 2, timeout (in secs)

auth'endpoint$

String

in

URL determined by service provider. For example, Google uses "https://accounts.google.com/o/oauth2/v2/auth"

token'endpoint$

String

in

URL determined by service provider. For example, Google's API uses "https://www.googleapis.com/oauth2/v4/token"

challenge$

String

in

Optional challenge string

scope$

String

in

Scope of the request, typically a URL, e.g. "https://mail.google.com"

refresh'token$

String

in

Usage depends on opcode.

response$

String

out

Response (typically in the form of a JSON document). Argument does not auto-expand, so make sure it is sufficiently large.

handle

X8

in/out

Value returned by op 1 and passed to op 2

stsmsg$

String

out

Status message. If S,0, must be pre-initialized to desired maximum length.

file$

String

in

For op 1, if specified, the response tokens are written directly to the specified file. For op 3, if specified and the refresh_token$ parameter is "", then the refresh_token string is retrieved from the file, and the file is updated with the new access_token. In either case, the response is also returned in the response$ parameter.

add'param

String

in

Should be in the form of a comma-delimited list of name=value pairs, e.g. "token_access_type=offline,foo=bar"

 

See Also

Sample program OAUTH2 in EXLIB:[908,77]

History

2024 May, A-Shell 7.0.1759:  New optional parameter add'param allows specification of additional authorization or token query parameters, which are required by some services. This requires ashnet 1.14.195 or higher.

2018 October, A-Shell 6.5.1648:  Function c to A-Shell