Forum Discussion

Suchith's avatar
8 years ago

How to Make REST API V1 Call using OAuth Access Token.

Hello,

I need help to perform REST API V1 call using OAuth Access Token. I referred https://community.lithium.com/t5/Developer-Documentation/bd-p/dev-doc-portal?section=commv1&page=apicall#constructingTheUrl and https://community.lithium.com/t5/Developer-Documentation/bd-p/dev-doc-portal?section=oauth2, but unable to find the solution.

I followed the example given in Community API V1 Documentation URL format with OAuth and got an error.

Please let me know.

Thanks,

Suchith

4 Replies

  • Suchith  - You need to authorize using session key for accessing API V1.

     

    This call will return session key which you can use while accessing API V1.

     

    https://yourcommunity.com/restapi/vc/authentication/sessions/login?user.login=<login>&user.password=<password>

     

    Pass the session key generated by the first call on restapi.session_key parameter.

    https://yourcommunity.com/restapi/vc/users/login/SuzieH/id?restapi.session_key=QItJhuKf3qhcLD8XYqmTncZrcBbWhcW_c9xd76H2Cgs.

     

     

    Here is the documentation https://community.lithium.com/t5/Developer-Documentation/bd-p/dev-doc-portal?section=sessionauth

  • Suchith's avatar
    Suchith
    Ace
    8 years ago

    Hi TariqGrazitti,

    Thanks for the reply, but my question is how to make Rest call using OAuth Access Token.

    In documentation they have mentioned OAuth will support both Community API V1 and Community API V2 call.

     

    I can successful make API V1 call using session key, but i want to know how it can be achieved using OAuth Access token.

    Thanks,

    Suchith

  • Suchith - 

    I assume you already have received the access token using OAuth flow as mentioned here https://community.lithium.com/t5/Developer-Documentation/bd-p/dev-doc-portal?section=oauth2#authorize 

     

    For API v1 you need to send request headers as below. 

     

    client-id: <your-client-id>
    authorization: Bearer <access token>
    Content-Type: application/json

     

     

    The URL will look like below. 

    https://api.lithium.com/community/v1/<tenant_id>/users

    Example call to get posts

     

    https://api.stage.lithium.com/community/v1/<tenant_id>/posts

     

     

  • Suchith's avatar
    Suchith
    Ace
    8 years ago

    Thanks Tariq,

    I was missing Bearer in the Authorization and Authorization URL must be URL Decoded.


    Suchith.