Solenergikvalitet API

OAuth

OAuth Introduction

Endpoints

EndpointURL
Authorizationhttps://auth.solenergikvalitet.se/authorize
Tokenhttps://auth.solenergikvalitet.se/token

Client Configuration

To integrate with our OAuth server, you can use the following configuration:

Authorization Code Flow

1. Redirect to Authorization Endpoint

Initiate the flow by redirecting the user to the authorization endpoint.

GET https://auth.solenergikvalitet.se/authorize

Query Parameters:

ParameterRequiredDescription
client_idYesYour Client ID (e.g., ifsek).
redirect_uriYesThe URL to redirect back to.
response_typeYesMust be code.
stateRecommendedA random string to prevent CSRF attacks.
code_challengeOptionalPKCE code challenge (S256). Recommended for security.
code_challenge_methodOptionalMust be S256 if code_challenge is provided.

Example URL:

https://auth.solenergikvalitet.se/authorize?client_id=ifsek&redirect_uri=https%3A%2F%2Fsolenergikvalitet.se%2Fsolcellsleverantor%2Fportal&response_type=code&state=4bff2b06-bbf8-4fbb-8ab9-7bd5f9eb10ed

2. Handle the Callback

After the user logs in, they will be redirected back to your redirect_uri with a code and state parameter.

Example Redirect:

https://solenergikvalitet.se/solcellsleverantor/portal?code=AUTHORIZATION_CODE&state=4bff2b06-bbf8-4fbb-8ab9-7bd5f9eb10ed

3. Exchange Code for Token

Exchange the authorization code for an access token by making a POST request to the token endpoint.

POST https://auth.solenergikvalitet.se/token

Form Data Parameters:

ParameterRequiredDescription
grant_typeYesMust be authorization_code.
codeYesThe code received in the callback.
redirect_uriYesMust match the redirect_uri used in step 1.
client_idYesYour Client ID.
code_verifierOptionalThe PKCE code verifier (if code_challenge was used).

Example Request:

curl -X POST https://auth.solenergikvalitet.se/token \
  -d "grant_type=authorization_code" \
  -d "code=AUTHORIZATION_CODE" \
  -d "redirect_uri=https://solenergikvalitet.se/solcellsleverantor/portal" \
  -d "client_id=ifsek"

4. Token Response

The server will respond with a JSON object containing the tokens.

{
  "access_token": "eyJhbGciOiJIUzI1...",
  "refresh_token": "eyJhbGciOiJIUzI1...",
  "expires_in": 3600,
}

5. Refresh Token

You can refresh the access token by making a POST request to the token endpoint with the grant_type set to refresh_token.

POST https://auth.solenergikvalitet.se/token

Form Data Parameters:

ParameterRequiredDescription
grant_typeYesMust be refresh_token.
refresh_tokenYesThe refresh token received in the token response.

The server will respond with a JSON object containing the tokens.

{
  "access_token": "eyJhbGciOiJIUzI1...",
  "refresh_token": "eyJhbGciOiJIUzI1...",
  "expires_in": 3600,
}