php - 'No grant type specified' error when testing OAuth in Stripe -


i testing oauth process of stripe in php. able authorization code in request in landing page.

but when curl request access token authorization code, getting error, says no grant type specified.

following code landing page far:

<?php $authorization_code = $_request['code'];  $params = array(); $params['grant_type'] = 'authorization_code'; $params['code'] = $authorization_code;  $url = 'https://connect.stripe.com/oauth/token';  $ch = curl_init(); $header = array (); curl_setopt( $ch, curlopt_httpheader, array ('accept: application/json', 'content-length: 0', 'authorization: bearer sk_test_secretkey' ) ); curl_setopt( $ch, curlopt_url, $url ); curl_setopt( $ch, curlopt_returntransfer, 1 ); curl_setopt( $ch, curlopt_post, true ); curl_setopt( $ch, curlopt_postfields,$params);  $response = curl_exec( $ch ); echo $response; ?> 

and error getting:

{ "error": "invalid_request", "error_description": "no grant type specified" } 

am missing ?

thanks.

you may have url encode parameters:

curl_setopt($ch, curlopt_postfields, http_build_query($params));

there's php example in stripe connect docs (https://stripe.com/docs/connect/oauth#sample-code). if you're still having trouble, might worth using kind of http proxy see you're actually sending on wire or contacting support@stripe.com.

hope helps!


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -