How possible get API token ?-VBForums
Results 1 to 3 of 3

Thread: How possible get API token ?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2009
    Location
    Belarus
    Posts
    88

    Angry How possible get API token ?

    Hi!
    How possible use any Http client (I think in vb that named like as "MSXML2.XMLHTTP" or anything else) for getting token?
    I can't adding parameter { "grant_type", "client_credentials" }
    All times get error, what
    {"error":"invalid_request","error_description":"The grant type was not specified in the request"}
    Very long time search solution but without results.
    In one forum I found this: http://stackoverflow.com/questions/3...in-asp-net-mvc

    But, how this code transpose to VB6.0? How use parameters client_credentials?

    And samples
    with curl:
    Code:
    curl -u 204da9b95e2480a3455f:7a4bbb61262fdf41d410645292a0489ba752c6b9 https://api.stormpath.com/v1/applications/$YOUR_APPLICATION_ID \
    -H 'Accept: application/json' -d 'grant_type=client_credentials'
    with php:
    PHP Code:
    $process curl_init("https://api.stormpath.com/v1/applications/$YOUR_APPLICATION_ID");
    curl_setopt($processCURLOPT_HTTPHEADER, array('Accept: application/json'));
    curl_setopt($processCURLOPT_USERPWD"204da9b95e2480a3455f:7a4bbb61262fdf41d410645292a0489ba752c6b9");
    curl_setopt($processCURLOPT_POST1);
    curl_setopt($processCURLOPT_RETURNTRANSFERTRUE);
    curl_setopt($processCURLOPT_POSTFIELDS, array('grant_type' => 'client_credentials'));
    $result curl_exec($process);
    curl_close($process); 
    Also, they wrote:
    To receive an authorization token, you must send a POST request indicating Basic Authentication to the authorization address (https://api.stormpath.com/v1/applica...APPLICATION_ID). The parameters for authorization must be Client ID and Client Secret from the OAuth application settings page. It is also necessary to pass the POST request parameter grant_type with the value client_credentials
    And
    The resource is available only through the HTTPS protocol.
    For all requests, you must specify the HTTP header 'Accept'. By default, it must be passed with 'application / json'.
    Last edited by sergeos; Mar 20th, 2017 at 05:45 AM.
    Ten Years After - 01 You Give Me Loving

  2. #2
    Hyperactive Member
    Join Date
    Feb 2017
    Posts
    385

    Re: How possible get API token ?

    Hello, try this:

    Add an internet transfer control Inet1 (menu Project, Components, Microsoft Internet Transfer Control).
    Set the Protocol property to icHTTPS.

    In a procedure:

    Code:
    Dim StrResult AsString
    
    Inet1.Execute "https://b2bapi.onliner.by/oauth/token", "POST", "{""client_id"":""your Client ID here"",""client_secret"":""your Client Secret here"",""grant_type"":""client_credentials""}", "Accept: application/json"
    
    Do While Inet1.StillExecuting
        DoEvents
    Loop
    
    StrResult = Inet1.GetChunk(1024, icString)
    If it worked, see what StrResult has, it must be a json, with the token inside.

    PS: I suggest to edit your post and not to post any valid client id and client secret in a forum.
    Last edited by Eduardo-; Mar 18th, 2017 at 07:13 PM.

  3. #3
    Hyperactive Member
    Join Date
    Feb 2017
    Posts
    385

    Re: How possible get API token ?

    If it didn't work, try this instead:

    Code:
    Inet1.Execute "https://your Client ID here:your Client Secret here@b2bapi.onliner.by/oauth/token", "POST", "{""grant_type"":""client_credentials""}", "Accept: application/json"

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.