Skip to content

Commit 4b33a54

Browse files
committed
obtain access tokent [netlify-build]
1 parent 29ee96b commit 4b33a54

File tree

1 file changed

+75
-7
lines changed

1 file changed

+75
-7
lines changed

src/connections/oauth.md

Lines changed: 75 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,82 @@ Once you've connected your source to OAuth, you can enable it. To enable your so
6767

6868
To disable your source from OAuth, turn the toggle off for **Enable OAuth**.
6969

70-
<!-- ## Request the access token
70+
## Obtain the access token
71+
You can obtain an access token once you create an OAuth application and enable a source to OAuth.
72+
73+
Access tokens are only valid within a region. The supported regional authorization servers are:
74+
* Oregon - https://oauth2.segment.io
75+
* Dublin - https://oauth2.eu1.segmentapis.com
76+
77+
To obtain the access token:
78+
79+
1. Create a JWT token with the header and payload as below:
80+
81+
Header
82+
```
83+
{
84+
"alg":"RS256",
85+
"typ":"JWT",
86+
"kid":"<<KID>>"
87+
}
88+
```
89+
90+
Payload
91+
```
92+
{
93+
"iss":"<<ISS>>",
94+
"sub":"<<SUB>>",
95+
"aud":"<<AUD>>",
96+
"iat":"<<IAT>>",
97+
"exp":"<<EXP>>",
98+
"jti":"<<JTI>>"
99+
}
100+
```
101+
102+
Field | Description
103+
------------ | -------------
104+
KID | The key ID of the public key in the OAuth application.
105+
ISS | The identifier of the JWT issuer.
106+
SUB | The OAuth application ID.
107+
IAT | The epoch time in seconds when the token was issued.
108+
EXP | The expiry time in seconds. This is expected to be valid only for a short duration under a minute.
109+
JTI | The unique identifer for the token.
110+
111+
2. Send a form-url-encoded POST request to the regional authorization server with the following parameters:
112+
113+
```
114+
grant_type=client_credentials
115+
client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer
116+
client_assertion=<<JWT>>
117+
scope=<<SCOPE>>
118+
```
119+
120+
Field | Description
121+
----- | ------------
122+
JWT | The signed JWT token string from Step 1.
123+
SCOPE | Scopes for which token is requested. See [supported scopes](#supported-scopes).
124+
125+
3. Include the access token in the Authorization header as a Bearer token. For example:
126+
127+
```
128+
Authorization: Bearer <access token>
129+
```
130+
131+
Below is an example cURL request:
132+
133+
```
134+
curl --location 'https://api.segment.io/v1/track' \
135+
--header 'Content-Type: application/json' \
136+
--header 'Authorization: Bearer <access token>' \
137+
--data-raw '{
138+
"event": "happy-path-a3ef8a6f-0482-4694-bc4d-4afba03a0eab",
139+
"email": "[email protected]",
140+
"messageId": "58524f3a-3b76-4eac-aa97-d88bccdf4f77",
141+
"userId": "123",
142+
"writeKey": "DmBXIN4JnwqBnTqXccTF0wBnLXNQmFtk"
143+
}
144+
```
71145
72-
To request the access token, run:
73-
74-
```
75-
./gentoken.sh -k <private-key.pem> -i <key_id> -a <oauth_app_id> | jq '.access_token'
76-
```
77-
-->
78146
79147
## Edit an OAuth application
80148
To edit an existing OAuth application:

0 commit comments

Comments
 (0)