LogoLogo
PostmanOpenAPIContact usSign up
  • Overview
    • Introduction
  • API Reference
    • POSTAdd Oauth2 Identity
PostmanOpenAPIContact usSign up
API Reference

Add Oauth2 Identity

POST
https://codecombat.com/api/users/:handle/o-auth-identities
POST
/api/users/:handle/o-auth-identities
1curl -X POST https://codecombat.com/api/users/:handle/o-auth-identities \
2 -H "Content-Type: application/json" \
3 -u "<username>:<password>" \
4 -d '{
5 "provider": "string"
6}'
Try it
200Successful
1{
2 "_id": "string",
3 "email": "string",
4 "name": "string",
5 "slug": "string",
6 "role": "string",
7 "stats": {
8 "gamesCompleted": 1,
9 "concepts": {
10 "string": 1
11 },
12 "playTime": 1
13 },
14 "oAuthIdentities": [
15 {
16 "provider": "string",
17 "id": "string"
18 }
19 ],
20 "subscription": {
21 "ends": "string",
22 "active": true
23 },
24 "license": {
25 "ends": "string",
26 "active": true
27 }
28}
Adds an OAuth2 identity to the user, so that they can be logged in with that identity. You need to send the OAuth code or the access token to this endpoint. 1. If no access token is provided, it will use your OAuth2 token URL to exchange the given code for an access token. 2. Then it will use the access token (given by you, or received from step 1) to look up the user on your service using the lookup URL, and expects a JSON object in response with an `id` property. 3. It will then save that user `id` to the user in our db as a new OAuthIdentity. In this example, we call your lookup URL (let's say, `https://oauth.provider/user?t=<%= accessToken %>`) with the access token (`1234`). The lookup URL returns `{ id: 'abcd' }` in this case, which we save to the user in our db.

Path parameters

handlestringRequired
The document's `_id` or `slug`.

Headers

AuthorizationstringRequired
Basic authentication of the form `Basic <username:password>`.

Request

This endpoint expects an object.
providerstringRequired
Your OAuth Provider ID.
accessTokenstringOptional
Will be passed through your lookup URL to get the user ID. Required if no `code`.
codestringOptional
Will be passed to the OAuth token endpoint to get a token. Required if no `accessToken`.

Response

This endpoint returns an object.
_idstring or null
emailstring or null
namestring or null
slugstring or null
rolestring or null
Usually either 'teacher' or 'student'
statsobject or null
oAuthIdentitieslist of objects or null
subscriptionobject or null
licenseobject or null
Was this page helpful?
Previous

Login User

Next
Built with
Your OAuth Provider ID.

Adds an OAuth2 identity to the user, so that they can be logged in with that identity. You need to send the OAuth code or the access token to this endpoint. 1. If no access token is provided, it will use your OAuth2 token URL to exchange the given code for an access token. 2. Then it will use the access token (given by you, or received from step 1) to look up the user on your service using the lookup URL, and expects a JSON object in response with an id property. 3. It will then save that user id to the user in our db as a new OAuthIdentity. In this example, we call your lookup URL (let’s say, https://oauth.provider/user?t=<%= accessToken %>) with the access token (1234). The lookup URL returns { id: 'abcd' } in this case, which we save to the user in our db.

The document’s _id or slug.

Will be passed through your lookup URL to get the user ID. Required if no code.

Basic authentication of the form Basic <username:password>.

Will be passed to the OAuth token endpoint to get a token. Required if no accessToken.