B4J Question [B4X] unsupported_grant_type in oauth

Alexander Stolte

Expert
Licensed User
Longtime User
I need to get the authorization code from the oauth, after i get the token from google, but i get the following error message:
B4X:
ResponseError. Reason: , Response: {"error":"unsupported_grant_type"}

Documentaton:

B4X:
Private Sub GetTokenFromAuthorizationCode (Code As String)
    Log("Getting access token from authorization code...")
    Dim j As HttpJob
    j.Initialize("", Me)
    Dim postString As String = $"code=${Code}&client_id=${mClientId}&grant_type=authorization_code&redirect_uri=${GetRedirectUri}"$
    postString = AddClientSecret(postString)

    j.PostString("https://xxx.supabase.co/auth/v1/token", postString)
    j.GetRequest.SetHeader("Content-Type", "application/x-www-form-urlencoded")
    j.GetRequest.SetHeader("apikey","your_supabase_apikey")

    Wait For (j) JobDone(j As HttpJob)
    If j.Success Then
        TokenInformationFromResponse(j.GetString)
    Else
        ResetToken
        RaiseEvent(False)
    End If
    j.Release
End Sub

example project is attached. Thanks
 

Attachments

  • B4XGoogleContacts.zip
    14.4 KB · Views: 164
Top