繁体   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?

为什么会收到错误请求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

  • 对于GET / oauth / v2 / authorize端点,您发送的clientSecret参数不是必需的,并且可能会干扰其后端的某些参数验证。 您需要传递的参数是:

    response_type
    client_id
    范围

    redirect_uri

    阅读以上URL,以了解每个参数的含义。

  • 确保您在查询参数redirect_uri中发送到GET https://login.uber.com/oauth/v2/authorize端点的URI的基础与Uber开发人员仪表板中为您的应用程序的“授权”标签所定义的URI相匹配。

    正如授权OAuth请求的文档所述:

    redirect_uri(可选)在资源所有者授权后,我们将重定向回的URI。
    URI的基础必须与您的应用程序注册期间使用的redirect_uri匹配。

    重定向URL可以是:

    1. 本地主机

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

    2. 任何HTTPS:// URL

      https://

    3. 定制方案

      自定义方案://

  • 确保您的重定向URI启用了HTTPS

    根据相同的授权和认证文档

     The Uber API implements the OAuth 2.0 standard for secure authentication and authorization. All communication with our servers must be over SSL (https://). 

    为了让您的域免费获得TLS证书,我建议我们加密证书颁发机构

  • 1)надоработатьснапримерhttp ://localhost/loacation.php ()

  • 2)ненадовырезатьлишниесимволыизпеременной代码

    require_once'uber.php'; $ settings = require_once'settings.php'; if(!isset($ _GET [“ code”]])){setcookie(“ AccessToken”,“”,time()-3600); 标头(“位置: 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']); 死(); }

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM