Zum Hauptinhalt springen

Retrieve an OAuth access token

POST/v2/oauth2/token
API-Version
v2
Request-Methode
POST
Operation-ID
user-oauth-retrieve-access-token

Exchange an authorization code or refresh token for an access token according to RFC6749‍. A successful exchange also rotates the refresh token.

Request​

Responses​

Format
application/json
Beschreibung

The authorization server issues an access token as described in RFC6749‍.

  • access_tokenstringrequired

    The access token issued by the authorization server.

  • expires_inintegerrequired

    The lifetime in seconds of the access token. For example, the value "3600" denotes that the access token will expire in one hour from the time the response was generated.

  • refresh_tokenstringrequired

    The refresh token issued by the authorization server.

  • scopestring

    The scope of the access token as described by RFC6749‍.

  • token_type"bearer"required

    The type of the token issued as described in RFC6749‍.

Content-Type: application/json

{
"access_token": "string",
"expires_in": 123,
"refresh_token": "string",
"scope": "string",
"token_type": "bearer"
}
{
"properties": {
"access_token": {
"description": "The access token issued by the authorization server.\n",
"type": "string"
},
"expires_in": {
"description": "The lifetime in seconds of the access token. For\nexample, the value \"3600\" denotes that the access\ntoken will expire in one hour from the time the\nresponse was generated.\n",
"type": "integer"
},
"refresh_token": {
"description": "The refresh token issued by the authorization server.\n",
"type": "string"
},
"scope": {
"description": "The scope of the access token as described by\n[RFC6749](https://datatracker.ietf.org/doc/html/rfc6749#section-3.3).\n",
"type": "string"
},
"token_type": {
"description": "The type of the token issued as described in\n[RFC6749](https://datatracker.ietf.org/doc/html/rfc6749#section-7.1).\n",
"enum": [
"bearer"
],
"type": "string"
}
},
"required": [
"access_token",
"refresh_token",
"token_type",
"expires_in"
],
"type": "object"
}

Nutzungsbeispiele​

$ curl \
--fail \
--location \
-X POST \
-H "Authorization: Bearer $MITTWALD_API_TOKEN" \
https://api.mittwald.de/v2/oauth2/token
import { MittwaldAPIV2Client } from "@mittwald/api-client";
import { assertStatus } from "@mittwald/api-client-commons";

const client = MittwaldAPIClient.newWithToken(process.env.MITTWALD_API_TOKEN);
const response = await client.user.oauthRetrieveAccessToken({});

assertStatus(response, 200);

use \Mittwald\ApiClient\Generated\V2\Clients\User\OauthRetrieveAccessToken\OauthRetrieveAccessTokenRequest;

$client = MittwaldAPIClient::newWithToken(getenv('MITTWALD_API_TOKEN'));

$request = (new OauthRetrieveAccessTokenRequest());
$response = $client->user()->oauthRetrieveAccessToken($request);

var_dump($response->getBody();

Auf dieser Seite