OIDC Authentication
Overview
Section titled “Overview”The Partner API is protected via OAuth 2.0 using the Client Credentials flow.
As the API is designed for machine-to-machine communication between backends, clients are required to continuously retrieve and refresh access tokens.
Retrieving an Access Token
Section titled “Retrieving an Access Token”To retrieve an access token, you need the client_id and client_secret exchanged during partner onboarding. If you do not yet have credentials, please reach out to your Free2move contact person.
Send a POST request to the token endpoint (see also the Authentication API Reference):
curl --request POST \ --url 'https://partner.free2move.com/auth/realms/partner/protocol/openid-connect/token' \ --header 'content-type: application/x-www-form-urlencoded' \ --data grant_type=client_credentials \ --data client_id=YOUR_CLIENT_ID \ --data client_secret=YOUR_CLIENT_SECRET \ -s| Parameter | Description |
|---|---|
grant_type |
Always client_credentials for machine-to-machine communication |
client_id |
The unique identifier of your OAuth 2.0 client, received during onboarding |
client_secret |
The matching secret for your client, received during onboarding |
On success, the endpoint returns a JSON payload containing the access_token:
{ "access_token": "ey...", "expires_in": 300, "refresh_expires_in": 0, "token_type": "Bearer", "not-before-policy": 0, "scope": "email profile"}Authenticating API Requests
Section titled “Authenticating API Requests”Pass the access_token in the Authorization header as a Bearer token:
curl --request GET \ --url 'https://partner.free2move.com/api/rental/partner/v1/vehicles' \ --header 'Authorization: Bearer ACCESS_TOKEN' \ --header 'Accept: application/json'Go Example
Section titled “Go Example”The complete example below retrieves an OAuth 2.0 access token and uses it to fetch available vehicles:
package main
import ( "encoding/json" "fmt" "io" "log" "net/http" "net/url" "os")
func main() { // 1. Read client_id and client_secret from environment variables data := url.Values{ "grant_type": {"client_credentials"}, "client_id": {os.Getenv("CLIENT_ID")}, "client_secret": {os.Getenv("CLIENT_SECRET")}, }
// 2. Request an access token (valid for 5 minutes) resp, err := http.PostForm( "https://partner.free2move.com/auth/realms/partner/protocol/openid-connect/token", data, ) if err != nil { log.Fatal(err) } defer resp.Body.Close()
var tokenRes map[string]any if err := json.NewDecoder(resp.Body).Decode(&tokenRes); err != nil { log.Fatal(err) }
// 3. Call the Rental vehicles endpoint using the Bearer token req, err := http.NewRequest( http.MethodGet, "https://partner.free2move.com/api/rental/partner/v1/vehicles", nil, ) if err != nil { log.Fatal(err) } req.Header.Set("Accept", "application/json") req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", tokenRes["access_token"]))
vehiclesRes, err := http.DefaultClient.Do(req) if err != nil { log.Fatal(err) } defer vehiclesRes.Body.Close()
// 4. Print the vehicle list response vehiclesBody, err := io.ReadAll(vehiclesRes.Body) if err != nil { log.Fatal(err) } fmt.Printf("%s\n", vehiclesBody)}