简体   繁体   English

无法通过uber api授权,我有server_token,client_id和client_secret,如何发送请求?

[英]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_id client_id
    scope 范围
    state
    redirect_uri redirect_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可以是:

    1. localhost 本地主机

      http://::1 http:// :: 1
      http://127.0.0.1 http://127.0.0.1
      http://localhost http://本地主机

    2. any HTTPS:// URL 任何HTTPS:// URL

      https:// https://

    3. 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.

相关问题 如何在 Kounta 中获取 client_id 和 client_secret 以使用基本访问授权? - How to get client_id & client_secret in Kounta To use Basic Access Authorization? 在yii2-oauth2-server中需要client_id和client_secret的资源所有者授权类型 - Resource Owner grant type requiring client_id and client_secret in yii2-oauth2-server 如何在使用OAuth时在Android应用上存储'client_secret'和'client_id'? - how to store 'client_secret' and 'client_id' on Android app when using OAuth? Oauth2 和 Laravel - `Client_id` 和 `Client_secret` - 在哪里放置、存储、调用? - Oauth2 & Laravel - `Client_id` & `Client_secret` - where to place, store, call? Bitstamp API 中的 client_id - client_id in Bitstamp's API 如何在PHP中为OAuth 2生成客户端ID和客户端密钥的唯一令牌? - How to generate unique token for Client Id & Client Secret for OAuth 2 in PHP? Facebook oauth client_id检索的令牌在获取提要中不起作用 - Facebook oauth client_id retrived token not working in getting feeds 将定制文件关联到client_id - Associate customizationFile to a client_id 如何在授权码和客户端密码的帮助下使用 PHP 获取 fortnox 访问令牌? - How to get fortnox access token with the help of authorization code and client secret using PHP? Paypal Rest API-如何获取客户端ID和机密? - Paypal Rest API - How to get client ID and secret?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM