Approve an authorization request
const url = 'https://api.nsin.ir/oauth/authorize';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"client_id":"example","redirect_uri":"example","response_type":"code","scope":"openid profile email offline_access","state":"example","code_challenge":"example","code_challenge_method":"S256","nonce":"example","consent":true}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.nsin.ir/oauth/authorize \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "client_id": "example", "redirect_uri": "example", "response_type": "code", "scope": "openid profile email offline_access", "state": "example", "code_challenge": "example", "code_challenge_method": "S256", "nonce": "example", "consent": true }'The server side of the panel’s /oauth/authorize page. It is called by
the NSIN panel with the signed-in user’s session, never by a relying
party: your application’s part of this step is the browser redirect to
{panel}/oauth/authorize?…, and the redirect back that follows.
Documented here because it defines the parameters your redirect must
carry. state is required. PKCE is mandatory for every client:
code_challenge_method must be S256 and code_challenge must be
BASE64URL(SHA256(code_verifier)) with a verifier of 43–128 unreserved
characters.
A first-party client is approved silently. A third-party client is
approved once per scope set: the first request answers
consent_required with the client’s name and the human descriptions of
the scopes, and the panel repeats the request with consent: true.
Authorizations
Section titled “Authorizations ”Request Body required
Section titled “Request Body required ”object
Must match one of the client’s registered URIs exactly.
Space-separated. Must include openid.
Example
openid profile email offline_accessOpaque value echoed back on the redirect. Required.
Echoed in the ID token.
Set by the panel when the user approves a third-party client.
Responses
Section titled “ Responses ”Either the URL to send the browser to, or a request for consent.
object
The registered redirect_uri with code, state and iss appended.
object
object
object
Example
{ "redirect_to": "https://app.example/auth/callback?code=nac_…&state=xyz&iss=https%3A%2F%2Fapi.nsin.ir"}invalid_client, invalid_redirect_uri, unsupported_response_type,
invalid_request (missing or malformed PKCE / state) or
invalid_scope.
The RFC 6749 error shape, used by the NSIN SSO endpoints only. It is
deliberately different from Error: OAuth clients match on the machine
error code, and only show error_description to a developer.
object
The machine-readable code.
A human-readable explanation. Never match on this.
Example
{ "error": "invalid_grant", "error_description": "authorization code is invalid or expired"}No panel session, or a legacy session token with no session id.
The single error shape used by every endpoint.
object
Human-readable description of what went wrong.
Example
{ "error": "read-only API key"}The account is not active.
The single error shape used by every endpoint.
object
Human-readable description of what went wrong.
Example
{ "error": "read-only API key"}