How to use HTTPAPI for OAuth 2.0 protocol authentication
Posted: Mon Jul 22, 2024 10:39 pm
Hi all,
i have application that uses HTTPAPI. Here are functions i use and every thing working fine.
http_setOption( 'Content-Type' : 'application/json' );
http_setOption('Accept':'application/json');
http_setauth(HTTP_AUTH_BASIC:%Trim(UserID):%Trim(Password));
rc = http_req( 'POST': url: *omit : result : *omit : postdata);
Want to use HTTPAPI for another application which uses OAuth 2.0 protocol for authentication and i do not know what functions to use to do this 2 step authentication, please help...
Here are documentation from API hosted site stamps.com: https://developer.stamps.com/rest-api/r ... qs_connect
SERA uses the industry-standard OAuth 2.0 protocol for authentication. Completing the authentication procedure for access to SERA requires a few steps.
1. Login: Application presents the server-hosted login page to the user in a browser.
2. Redirect with Authorization Code: Once the user logs in and authorizes the application, an authorization code is returned to the application.
3. Initial Token Generation: Application uses authorization code to generate the initial set of access and refresh tokens.
4. Refresh Token: Application uses the stored refresh token to generate a new access token as needed.
Authentication:
In order to access SERA, integrations must call the API with a valid access token. Access tokens can be generated with a valid authorization code from a user's login event or with an refresh token from an earlier login. The endpoints below detail how to login to receive an authorization code and how to turn that code into a valid set of access and refresh tokens.
Authorization URL: https://signin.testing.stampsendicia.com/authorize
Token URL: https://signin.testing.stampsendicia.com/oauth/token
Refresh URL: https://signin.testing.stampsendicia.com/oauth/token
Get Authorization Code:
Integrators call this endpoint to receive a 302 redirect to a hosted HTML login page. Once the user completes the login page, they will be redirected to the URL specified in redirect_uri with an authorization code contained in the code query parameter. For example, if the redirect_uri is "https://www.stamps.com", the user will be directed to "https://www.stamps.com/?code=<AuthorizationCode>" on successful login. Use this authorization code to generate an access_token.
QUERY PARAMETERS:
client_id
string
Client ID
Identifies the integrated application connecting to SERA
response_type
string
Value: "code"
Example: response_type=code
Response Type
Set to code for the authorization code flow
redirect_uri
string
Redirect URI
The login page will redirect to this URI on successful login
scope
string
Value: "offline_access"
Scope
Specify this scope value as offline_access in order to receive a refresh_token in the response
Responses:
302
Found
i have application that uses HTTPAPI. Here are functions i use and every thing working fine.
http_setOption( 'Content-Type' : 'application/json' );
http_setOption('Accept':'application/json');
http_setauth(HTTP_AUTH_BASIC:%Trim(UserID):%Trim(Password));
rc = http_req( 'POST': url: *omit : result : *omit : postdata);
Want to use HTTPAPI for another application which uses OAuth 2.0 protocol for authentication and i do not know what functions to use to do this 2 step authentication, please help...
Here are documentation from API hosted site stamps.com: https://developer.stamps.com/rest-api/r ... qs_connect
SERA uses the industry-standard OAuth 2.0 protocol for authentication. Completing the authentication procedure for access to SERA requires a few steps.
1. Login: Application presents the server-hosted login page to the user in a browser.
2. Redirect with Authorization Code: Once the user logs in and authorizes the application, an authorization code is returned to the application.
3. Initial Token Generation: Application uses authorization code to generate the initial set of access and refresh tokens.
4. Refresh Token: Application uses the stored refresh token to generate a new access token as needed.
Authentication:
In order to access SERA, integrations must call the API with a valid access token. Access tokens can be generated with a valid authorization code from a user's login event or with an refresh token from an earlier login. The endpoints below detail how to login to receive an authorization code and how to turn that code into a valid set of access and refresh tokens.
Authorization URL: https://signin.testing.stampsendicia.com/authorize
Token URL: https://signin.testing.stampsendicia.com/oauth/token
Refresh URL: https://signin.testing.stampsendicia.com/oauth/token
Get Authorization Code:
Integrators call this endpoint to receive a 302 redirect to a hosted HTML login page. Once the user completes the login page, they will be redirected to the URL specified in redirect_uri with an authorization code contained in the code query parameter. For example, if the redirect_uri is "https://www.stamps.com", the user will be directed to "https://www.stamps.com/?code=<AuthorizationCode>" on successful login. Use this authorization code to generate an access_token.
QUERY PARAMETERS:
client_id
string
Client ID
Identifies the integrated application connecting to SERA
response_type
string
Value: "code"
Example: response_type=code
Response Type
Set to code for the authorization code flow
redirect_uri
string
Redirect URI
The login page will redirect to this URI on successful login
scope
string
Value: "offline_access"
Scope
Specify this scope value as offline_access in order to receive a refresh_token in the response
Responses:
302
Found