0% found this document useful (0 votes)
27 views

What Is Needed To Create An OAuth Flow

Uploaded by

Rome Say
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

What Is Needed To Create An OAuth Flow

Uploaded by

Rome Say
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

YM Support Home > Technical > API Unfollow 

What is needed to create an OAuth ow?


Table of Contents
Overview

Prerequisites

Getting the user's authorization

Getting the Access Token

Authenticating the user to Services

Getting the authenticated user's pro le information

Overview
The general OAuth ow consists of the following steps:

1. The user signs in on your YM site and authorizes your app.


2. Get the code from the authorization and get the access token.
3. Use the access token to authenticate the user.
4. Use the session from the authentication to make calls to the API on behalf of the user (e.g. getting pro le
information)

Support
Prerequisites
In order to follow along this brief walkthrough, you need to have OAuth keys created. Please refer to this article for
assistance in creating them: How to create OAuth App Credentials

We also highly recommend you have a general understanding of how the YM REST API works and how the SessionId is
used for an authenticated session. Please refer to this article: Getting Started with the REST API

Getting the user's authorization


In order to get the user's authorization, you need to have them log in from a speci c path on your site (lock.aspx) along
with some parameters. Let's take the following table and add example to them:

Parameter Description Example

Base URL Primary URL for your YM site https://www.professional.com

The App ID of your OAuth app as


app_id AbCdEfG12345
generated in YM

redirect_uri The redirect URL, as entered in https://members.pro.app/callback


your OAuth app

The scope(s) established in your


OAuth app: basic_pro le,
scope basic_pro le
full_pro le, or both
(basic_pro le,full_pro le)

Taking these values, we would build the URL as follows:

https://www.professional.com/lock.aspx?
app_id=AbCdEfG12345&redirect_uri=https://members.pro.app/callback&scope=basic_pro le

The parameters can be in any order, but this is where you would direct your members to sign in and authorize the
application. On successful authorization, the browser will redirect to your redirect url
(e.g. https://members.pro.app/callback) with a query string parameter "code" that is used to get the access token (e.g.
https://members.pro.app/callback?code=code101010).

Getting the Access Token


After authorization and getting redirected to the redirect URL, this route should be handling the code that is passed as
a query string. The parameter is labeled as "code" and is used with the GetAccessToken service in the REST API.
Continuing on our example, here are the parameters needed:

Parameter Description Example

GetAccessToken Route The route to get the access token /OAuth/GetAccessToken

The App ID of your OAuth app as


AppID AbCdEfG12345
generated in YM

The App Secret of your OAuth app


AppSecert SECRETAbCdEfG12345
as generated in YM

The grant type to get the Access


GrantType Token. Possible values: Code, Code
RefreshToken

The code from the authorization


* Code code101010
step

The refresh token of the record in


* RefreshToken refresh101010
question

In this case, we would be using the Code parameter and not the RefreshToken parameter. The refresh token is used
when you already have the refresh token and need to get a new access token. Once you have all your parameters, you
would make the following call:

Endpoint Type

https://ws.yourmembership.com/OAuth/GetAccessToken POST

Body
{
AppId: "AbCdEfG12345",
AppSecert: "SECRETAbCdEfG12345",
GrantType: "Code",
Code: "code101010"
}

A successful response from this call will return a series of datapoints including the AccessToken and it's expiration. This
token will be used to authenticate to the REST Services. For this example, let's say the access token returned
was a1b2c3d4e5.

Authenticating the user to Services


Now that you have the access token, you can now pass that to the Auth service to get the necessary session created.
Continuing on our example, here are the parameters needed:

Parameter Description Example

The route to authenticate to


Auth Route /Ams/Authenticate
services

The App ID of your OAuth app as


ConsumerKey AbCdEfG12345
generated in YM

The App Secret of your OAuth app


ConsumerSecret SECRETAbCdEfG12345
as generated in YM

The access token returned from


AccessToken a1b2c3d4e5
the GetAccessToken service

ClientID The ID of your YM site 12345

The type of user authenticating to


UserType the service. Possible values: Admin, Member
Member

Once you have all of your parameters situated, you would make the following call:

Endpoint Type

https://ws.yourmembership.com/Ams/Authenticate POST

Body

{
ConsumerKey: "AbCdEfG12345",
ConsumerSecret: "SECRETAbCdEfG12345",
AccessToken: "a1b2c3d4e5",
ClientID: 12345,
UserType: "Member",
}
A successful authentication will return another series of values including two very important values:

SessionId: The value to be passed into the "X-SS-ID" header for subsequent requests.

MemberId: The ID to be passed in any route variables for the Member.

These two, in conjunction with the ClientID, will be used to make calls to other services as needed.

Getting the authenticated user's pro le information


Since we authenticated the user with the Auth service, we can now use the Session ID, the Member ID, and the Client
ID to get the member's pro le information using the BasicMemberPro le service. We are using this service versus the
MemberPro le service as our application is only using the basic_pro le scope. Continuing our example, here are the
parameters needed:

Parameter Description Example

/Ams/{ClientID}/Member/
BasicMemberPro le Route The route to get the user's information
{MemberID}/BasicMemberPro le

The SessionId returned from the auth


X-SS-ID AUTH123
service

ClientID The ID of your YM site 12345

The ID of your member record as


MemberID 987654321
returned from the auth service

Once you have all of your parameters situated, you would make the following call:

Endpoint

https://ws.yourmembership.com/Ams/12345/Member/987654321/BasicMemberPro le

Type

GET

Headers

{
...
X-SS-ID: "AUTH123",
...
}

On successful response, you will see your member's information as speci ed in the metadata.
Was this article helpful? 👍 👎 0 out of 0 found this helpful

Powered by Zendesk

You might also like