Website

Grant type: authorization_code

Last update: 29.01.2024

Grant type: authorization_code

Client must specify Callback URL. You can specify more than one Callback URL. Please avoid special chars like & (multiple), # in Callback URL.

Flow:

On Application site user clicks on button “Authenticate with OLX”.

Auth URL: /oauth/authorize/?client_id=XXX&response_type=code&state=XXX&scope=read write v2&redirect_uri=XXX

Parameter state is optional. It will be returned in step 4 so application can validate if response is not crafted by someone else.

Parameter redirect_uri is optional if you specified only one Callback URL. If you have more than one Callback URL parameter redirect_uri is mandatory. Please avoid special chars like & (multiple), # in redirect_uri.

URL will be used in step 4. redirect_uri should base on defined earlier Callback URL.

Example:

Callback URL: http://myadomain.com/auth/connect

Auth URL: https://www.olx.ro/oauth/authorize/?client_id=123&response_type=code&state=x93ld3v&scope=read+write+v2&redirect_uri=http://myadomain.com/auth/connect

Example 2:

Callback URL: http://myadomain.com/auth/connect

Auth URL: https://www.olx.ro/oauth/authorize/?client_id=123&response_type=code&state=x93ld3v&scope=read+write+v2

If you have only one Callback URL you don’t have to pass redirect_uri parameter.

User is redirected to OLX login screen User logs in and authorize client User is redirected back to redirect_uri with some additional query parameters: code and state (optional).

Example: http://myadomain.com/auth/connect?code=d34feg43g456g&state=x93ld3v

Application exchange received code to access token by grant type authorization_code.

Request to get access token, sent to /api/open/oauth/token endpoint, should have:

		{
   "grant_type" : "authorization_code",
   "client_id" : "",
   "client_secret" : "",
   "code" : "",
   "scope" : "v2 read write",
   "redirect_uri" : "http://myadomain.com/auth/connect"
}			
		
Copied to clipboard

Note: redirect_uri parameter is optional unless you use parameter redirect_uri in Auth URL in step 1. If you use redirect_uri in step 1, then redirect_uri is also mandatory in request in step 5.