Forum Discussion

vishwajeet_hol's avatar
10 years ago

Oauth 2.0 : facing issue to get authorization code

Hi,

 

I am trying to implement Oauth 2.0 authorization. I am not familier with it.

I have referred below link on lithosphere :

http://community.lithium.com/t5/Community-API-v2/OAuth-2-0-authorization-grant-flow/ta-p/138402

 

Done POST call through 'poster'(add on) on Firefox using following details :

URL : https://<community_url>/auth/oauth2/authorize

client_id=<client_ID_of_community>
response_type=code
redirect_uri=https://<community_url>/getaccesstoken

 

But facing issue to get authorization code, which is very first step of OAuth 2.0 authorization grant flow.

Am I going in right way ?

I have confusion about 'redirect_uri' parameter. What it should be ? 

 

 

Let me know if you have any suggetion for the same.

Thank you in advance.

 

Regards,

Vishwajeet.

24 Replies

  • darmlin's avatar
    darmlin
    Contributor
    8 years ago

    Thanks rajpi

     

    I'm using the same redirect-uri as I do to obtain the authorization code.  When I tweak it intentionally to something invalid I receive (leading me to believe unchanged it may be valid):

    "response":{"httpCode":400,"message":"Bad Request","status":"client_id + client_secret + redirect_uri is NOT not valid"}}

     

    I've checked/tried encoding/decoding the authorization code and other values with the same result (and generated new fresh authorization codes) and get this response: 

     

    {"response":{"httpCode":401,"message":"Unauthorized","status":"Authorization code is NOT authorized"}}

     

    Double checking permissions again.

     

    I'm testing from curl and python/urrlib2 with the same result.

     

    Thanks for the help

     

     

  • tealiumjustin's avatar
    tealiumjustin
    Expert
    8 years ago

    Does this work with SSO?

     

    I'm also trying to authorize a back-end API following the directions here, under the heading "Using the authorization grant flow via a back-end API call":

    https://community.lithium.com/t5/Developer-Documentation/bd-p/dev-doc-portal?section=oauth2

     

    We use SSO for access to our community. I can't figure out how to get the authorization code. And, as previous replies have shown, the /auth/v1/accessToken request only returns a "400 Bad Request" with this body:

     

     

    {
        "response": {
            "httpCode":400,
            "message":"Bad Request",
            "status":"client_id + client_secret + redirect_uri is NOT not valid"
        }
    }

     

     

     

     

  • I've been struggling with this error for a couple of weeks. I was finally able to get a code. The trick was making sure that the Client ID was URL encoded. The redirect_uri must NOT be encoded. Once I did that, the response has the code I was looking for in the URL. This conflicts with the developer documentation which shows an un-encoded client ID and an encoded return_uri.

     

    https://community.lithium.com/t5/Developer-Documentation/bd-p/dev-doc-portal?section=oauth2