简体   繁体   English

尝试弄清楚如何在不使用PHP CLI的服务器的情况下使用oAuth2

[英]Trying to figure out how to use oAuth2 without a server using PHP CLI

What I want do is be able to use oAuth2 from a CLI app that I wrote. 我想要做的是能够使用我编写的CLI应用程序中的oAuth2。 The app works, but right now I have to goto this website right now and pull my token off the returned URL https://beta.geoloqi.com/oauth/authorize?response_type=code&client_id= $clientid&redirect_uri=http://geoloqi.com 该应用程序可以运行,但是现在我必须立即转到该网站,并从返回的URL中提取我的令牌https://beta.geoloqi.com/oauth/authorize?response_type=code&client_id= $ clientid&redirect_uri = http:// geoloqi。 com

The oAuth2 specification sys I can use localhost as the redirect_uri, but I've not been able to figure out to get it to work. 我可以使用oAuth2规范sys本地主机作为redirect_uri,但是我一直无法弄清楚它能否正常工作。 I am not running a web server, and would rather not have to open any ports on my router to make this work. 我没有在运行Web服务器,因此不想在路由器上打开任何端口即可进行这项工作。 (I can open a port if I need to) (如果需要,我可以打开一个端口)

I am using PHP v5.3.3 on currently on a linux (Ubuntu) box, but I need to also run the script from Windows as well. 我目前在Linux(Ubuntu)机器上使用PHP v5.3.3,但是我还需要从Windows运行脚本。

the idea is for it to be automated, and not have me put the token in everytime. 这个想法是要使其自动化,而不是让我每次都放入令牌。

IS there any way to do this from the CLI or will I need to run a server? 是否可以通过CLI进行任何操作,还是需要运行服务器?

Thanks for the help LeRoy 感谢您的帮助LeRoy

You would probably want to use the Authentication from a Device flow instead of the web flow. 您可能要使用“设备”流中的“身份验证”,而不是Web流。 The Authentication from a Device flow requires you to pass in the username and password in exchange for the access token. 来自设备流的身份验证要求您传入用户名和密码,以换取访问令牌。 You would need to talk to the OAuth provider (Geoloqi in your case) on how to set up your account to use this flow. 您需要与OAuth提供商(在您的情况下为Geoloqi)谈谈如何设置帐户以使用此流程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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