How to implement OAuth Mashery 2.0 | Mashery OAuth 2.0

Devops

  • Blog
  • How to implement OAuth Mashery 2.0 | Mashery OAuth 2.0
Devops
Devops1 Sept 2021

How to work with Mashery OAuth 2.0

TIBCO Mashery OAuth 2.0 implementation guides you how to create API along with various ways of obtaining access and generating tokens. Follow the below steps to know how Mashery OAuth 2.0 works.

Step 1: - First you need to create one API definition.

Step 2: -- Move to the API definitions and click on the desired API.

API definitions

Step 3: -- A screen with a default method appears now.

step3step 3-1

Step 4: -- Go to Security Settings in left hand side of the menu bar

Go to Security Settings

Step 5: -- You will see the Following things which shows that OAuth 2.0 as Disabled, it is wise to enable that.

Steps for enabling OAuth 2.0

Step 5

Step 6: - After enabling the OAuth 2.0, follow the steps to enable things as shown below.

API defination security settingAcme outh

Step 7: - Now, just go back to the path “API Definitions /Acme OAuth” and click on the below mentioned button to create auth endpoint

endpoint, Acme OAuth

After clicking on this token, you need to create one more endpoint and that will be visible now

tibco end point create

end point Acme OAuth

Now we need to enable OAuth for our Endpoints

Step 8: After enabling it, you need to click on the default endpoint

After enabling it

Step 9: - Click the default option and go to key and method Detection as shown below and configure like this and then hit save.


end point key & method detectionend point key & method detection2

Step 10: Now, we need to create one package for the same definition. So, go to home: -- API Packages

Just create one new package and create one plan name Starter

API Packages

Click on OAuth. Now, you need to create one plan under “Starter” as shown below.

Plan's OAuth

To make it accessible, click the icon (settings).

To make it accessible

Activate the mentioned options for the same.

API package Key Properties

Go to the access control and try to make the plan accessible to users

API plan Access Control

Next, go to Plan Designer and assign a package to particular API and endpoints as shown and then click Save .

Plan Designer

Step :11 We need to update its IO Doc. Go to design and move to the Interactive Documentation

API Marketplace

You will get list of all IO docs as shown in this image

Intercative Documentation

Step: -12 Click on title name

Click on title name

Now, you can see the Interactive Document for this API Definition.

nteractive Document for this API Definition.

Important Note: -- Please use below mentioned Code Snippet to use values in your API.

"auth": {

"oauth": {

"version": "2.0",

"base_uri": "",

"authorize_uri": "http://evalXXXX.api.mashery.com/oauth2/auth/<api_id>",

"access_token_uri": "http://evalXXXX.api.mashery.com/oauth2/token",

"access_token_location": "header",

"auth_flows": [ "client_cred" ],

"options": {}

}

},

For API_Id In above snippet kindly refer the screenshot below, In Browser URL this is your api_id

interactive Documentation

Now we need to test it in our Developer portal

Here are the steps that you need to follow for the successful testing:

Step :1 Login to your Developer portal http://evalxxxxxx.mashery.com/

Step 2: Go to your account and create one Application for the same.

Step 3: Once it is done, go to the Interactive tab in the Developer portal.

Step 4: Now, you can see your application as in the image.

Developer portal

Step 5: Once done, you will find this “Get Access Token” and click on it.

Get Access Token

then you can hit on your API and you will get response as shown in the image

response  status