[英]Can not authorization by uber api, I have server_token, client_id and client_secret, how send request?
Why do I get the error request uri? 为什么会收到错误请求uri?
https://login.uber.com/oauth/v2/authorize?response_type=code&client_id= ".$settings['global']['clientId'].'&clientSecret="'.$settings['global']['clientSecret'].'&scope=all_trips&redirect_uri=http://'.$_SERVER['HTTP_HOST'].'token.php https://login.uber.com/oauth/v2/authorize?response_type=code&client_id=“。$ settings ['global'] ['clientId']。'&clientSecret =”'。$ settings ['global'] [' clientSecret']。'&scope = all_trips&redirect_uri = http://'.$_SERVER ['HTTP_HOST'] .'token.php
For the GET /oauth/v2/authorize endpoint the clientSecret parameter that you send is not required and may interfere with some parameter validation on their backend. 对于GET / oauth / v2 / authorize端点,您发送的clientSecret参数不是必需的,并且可能会干扰其后端的某些参数验证。 The parameters you need to pass are:
您需要传递的参数是:
response_type
response_type
client_idclient_id
scope范围
state州
redirect_uriredirect_uri
Read the above URL to understand what each parameter means. 阅读以上URL,以了解每个参数的含义。
Make sure the base of the URI you send in the query parameter redirect_uri to the GET https://login.uber.com/oauth/v2/authorize endpoint matches the one defined in the Uber Developers Dashboard for your app, Authorizations tab. 确保您在查询参数redirect_uri中发送到GET https://login.uber.com/oauth/v2/authorize端点的URI的基础与Uber开发人员仪表板中为您的应用程序的“授权”标签所定义的URI相匹配。
As the docs for the authorize OAuth request says: 正如授权OAuth请求的文档所述:
redirect_uri (optional) The URI we will redirect back to after an authorization by the resource owner.
redirect_uri(可选)在资源所有者授权后,我们将重定向回的URI。
The base of the URI must match the redirect_uri used during the registration of your application.URI的基础必须与您的应用程序注册期间使用的redirect_uri匹配。
The redirect URL can be: 重定向URL可以是:
http://::1
http:// :: 1
http://127.0.0.1http://127.0.0.1
http://localhosthttp://本地主机
any HTTPS:// URL 任何HTTPS:// URL
https://
https://
a custom scheme 定制方案
custom-scheme://
自定义方案://
Make sure your redirect URI is HTTPS enabled 确保您的重定向URI启用了HTTPS
According to the same authorization and authentication documentation : 根据相同的授权和认证文档 :
The Uber API implements the OAuth 2.0 standard for secure authentication and authorization. All communication with our servers must be over SSL (https://).
For getting a TLS certificate at no cost for your domain I recommend Let's Encrypt Certificate Authority 为了让您的域免费获得TLS证书,我建议我们加密证书颁发机构
1) надо работать с например http://localhost/loacation.php ( )
1)надоработатьснапримерhttp ://localhost/loacation.php ()
2) не надо вырезать лишние символы из переменной code
2)ненадовырезатьлишниесимволыизпеременной代码
require_once 'uber.php'; require_once'uber.php'; $settings = require_once 'settings.php';
$ settings = require_once'settings.php'; if ( !isset( $_GET["code"] ) ) { setcookie( "AccessToken", "", time() - 3600);
if(!isset($ _GET [“ code”]])){setcookie(“ AccessToken”,“”,time()-3600); Header( "Location: https://login.uber.com/oauth/v2/authorize?response_type=code&client_id= ".$settings['global']['client_id'].'&redirect_uri=localhost/location.php&client_secret='.$settings['global']['client_secret']);
标头(“位置: https ://login.uber.com/oauth/v2/authorize?response_type=code&client_id = ”。$ settings ['global'] ['client_id']。'&redirect_uri = localhost / location.php&client_secret =' 。$ settings ['global'] ['client_secret']); die();
死(); }
}
$result = postKeys("https://login.uber.com/oauth/v2/token", array( 'client_secret'=>$settings['global']['client_secret'], 'client_id'=>$settings['global']['client_id'], 'grant_type'=> 'authorization_code', 'redirect_uri'=> 'http://localhost/location.php', 'code'=> $_GET["code"], ), array('Content-type: application/x-www-form-urlencoded') ); // после получения ответа, проверяем на код 200, и если все хорошо, то у нас есть токен if ($result["code"]==200) { $result["response"]=json_decode($result["response"],true); $token=$result["response"]["access_token"]; $new = new Token($settings); $new->setToken($token); }else echo "не правильный код: ".$result["code"].' '.$result['response'];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.