Connection Information

To perform the requested action, WordPress needs to access your web server. Please enter your FTP credentials to proceed. If you do not remember your credentials, you should contact your web host.

Connection Type

OAuth Grant Types – PB Docs 2022 – PowerBuilder Library

OAuth Grant Types – PB Docs 2022

OAuth Grant Types

PowerBuilder supports getting secured data from the OAuth 2.0
authorization server. The Bearer access token is supported, and the
following grant types are supported:

  • Authorization Code

  • Implicit Flow

  • Client Credentials

  • Extension (or Refresh Token)

  • Resource Owner Password

Authorization Code and Implicit Flow can be implemented using the
WebBrowser control and the OAuthClient object. The WebBrowser control
gets the authorization code. The OAuthClient object obtains the access
token and protected resources.

Client Credentials, Extension, and Resource Owner Password can be
implemented using the OAuthClient object (including TokenRequest,
TokenResponse, OAuthRequest, and ResourceResponse). The OAuthClient
object obtains the access token and protected resources. The
TokenRequest and TokenResponse objects get or set the access token
request and response. The OAuthRequest and ResourceResponse objects get
or set the protected resource request and response.

PowerBuilder supports the Basic HTTP authentication theme (see
Example 2 (using
HTTPClient)
), and does not support the following HTTP
authentication themes: Digest, NTLM, Passport, and Negotiate.

As shown in the following figure, to access data from the OAuth
2.0 authorization server, there are mainly two steps:

  1. Use the HTTP Post method to request the access token from the
    authorization server;

  2. Set the access token in the HTTP Authorization header, and use
    Get method to request the data from the resource server.

oauth.png

This section provides code examples to demonstrate how to get data
using different grant type.

And the examples will use the following server settings and
parameters.

  For requesting
access token

Token URL and settings

TokenLocation=”https://xxx.xxx.xxx/oauth2/token”

ClientID=”367c4163ddc1427d96655cd220c6714b”

Secret=”4079f8749939446cbc81fd0c27709187″

Parameters

Authorization Server
(GrantType=”authorization_code”):

  • UserName=”username” in the following example.

  • Password=”password123″ in the following
    example.

  • Scope=”https://www.googleapis.com/auth/youtube”

  • Redirect=”https://www.appeon.com/callback”

  • Authorization
    URL=”https://accounts.google.com/o/oauth2/auth”

Implicit Flow:

  • UserName=”username” in the following example.

  • Password=”password123″ in the following
    example.

  • Scope=”https://www.googleapis.com/auth/youtube”

  • Redirect=”https://www.appeon.com/callback”

  • Authorization
    URL=”https://accounts.google.com/o/oauth2/auth”

Client Credentials
(GrantType=”client_credentials”):

  • Scope=”dscode dsperf” in the following example. This
    parameter is optional.

Extension
(GrantType=”refresh_token”):

  • refresh_token=
    “8a9767b5f7e59245339cb965ce4bfdf589e155535c042a8b2a90d89093eefb7e”

  • Scope=”testcode upcode profile offline_access” in
    the following example. This parameter is optional.

Resource Owner Password
(GrantType=”password”):

  • UserName=”username” in the following example.

  • Password=”password123″ in the following
    example.

  • Scope=”testcode” in the following example. This
    parameter is optional.

Format

JSON

Required Authentication

Yes (“Basic
…”)

Note: The WebBrowser control does not support
the OAuth basic authentication, therefore, when implementing the
Authorization Code grant type with the WebBrowser control, the
user will have to specify the authorization username and
password.

Successful Responses:

Return the following value
and JSON string if succeed:

200 OK {“access_token”:
“0374672c0f9a83d7e808725bd8ea748a250f2b8e151b9d93f2afa7805ec2dd52”,
“expires_in”: 3600, “token_type”: “Bearer”, “refresh_token”:
“8a9767b5f7e59245339cb965ce4bfdf589e155535c042a8b2a90d89093eefb7e”}

  For requesting
resource

Resource URL

https://xxx.xxx.xxx/order/getall

Format

JSON

Required Authentication

Yes (“Bearer
…”)

Successful Responses:

Return the following value
and JSON string if succeed:

200 OK [{“person_Title”:
“Mr.”, “person_Firstname”: “Kevin”, “person_Middlename”: “F.”,
“person_Lastname”: “Browne”, “customer_Modifieddate”:
“2014-09-12T11:15:07.263”, “customer_Customerid”: 29592,
“sumamt”: 80468.2110, “avgamt”: 10058.5263}]


Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x