AuthenticationService

This interface defines the Retrofit service for handling various authentication-related API calls.

It includes methods for creating API users, retrieving API user details, generating API keys, and obtaining access tokens. Each method corresponds to a specific endpoint in the MTN MOMO API.

Functions

Link copied to clipboard
@FormUrlEncoded
@POST(value = "/{productType}/{apiVersion}/bc-authorize")
abstract suspend fun bcAuthorize(@Path(value = "productType") productType: String, @Path(value = "apiVersion") apiVersion: String, @Field(value = "login_hint") loginHint: String, @Field(value = "scope") scope: String, @Field(value = "access_type") accessType: String, @Header(value = "Ocp-Apim-Subscription-Key") productSubscriptionKey: String, @Header(value = "X-Target-Environment") environment: String): Response<BackChannelAuthorize>

Initiates a backchannel authorization (CIBA) request for the specified product type.

Link copied to clipboard
@POST(value = "/{apiVersion}/apiuser/{apiUser}/apikey")
abstract suspend fun createApiKey(@Path(value = "apiVersion") apiVersion: String, @Path(value = "apiUser") apiUser: String, @Header(value = "Ocp-Apim-Subscription-Key") productSubscriptionKey: String): Response<ApiKey>

Creates a new API key for the specified API user.

Link copied to clipboard
@POST(value = "/{apiVersion}/apiuser")
abstract suspend fun createApiUser(@Body providerCallBackHost: ProviderCallBackHost, @Path(value = "apiVersion") apiVersion: String, @Header(value = "X-Reference-Id") uuid: String, @Header(value = "Ocp-Apim-Subscription-Key") productSubscriptionKey: String): Response<ApiUser>

Creates a new API user.

Link copied to clipboard
@POST(value = "/{productType}/token/")
abstract suspend fun getAccessToken(@Path(value = "productType") productType: String, @Header(value = "Ocp-Apim-Subscription-Key") productSubscriptionKey: String): Response<AccessToken>

Obtains an access token for the specified product type.

Link copied to clipboard
@GET(value = "/{apiVersion}/apiuser/{apiUser}")
abstract suspend fun getApiUser(@Path(value = "apiVersion") apiVersion: String, @Path(value = "apiUser") apiUser: String, @Header(value = "Ocp-Apim-Subscription-Key") productSubscriptionKey: String): Response<ApiUser>

Retrieves the details of an existing API user.

Link copied to clipboard
@FormUrlEncoded
@POST(value = "/{productType}/oauth2/token/")
abstract suspend fun getOauth2AccessToken(@Path(value = "productType") productType: String, @Header(value = "Ocp-Apim-Subscription-Key") productSubscriptionKey: String, @Header(value = "X-Target-Environment") environment: String, @Field(value = "grant_type") grantType: String = Constants.FormFields.CIBA_GRANT_TYPE, @Field(value = "auth_req_id") authReqId: String): Response<Oauth2AccessToken>

Obtains an OAuth2 access token for the specified product type.