简体   繁体   English

Oauth2与使用php和curl的metup,无法获得令牌

[英]Oauth2 Vs meetup using php and curl, fails to get token

respect to the whole stack exchange community, 尊重整个堆栈交换社区,

Tried to hold off for as long as i can(7 days) before asking, who/what is responsible for the following errors: 在询问以下错误之前,尝试在我能(7天)之内推迟进行尽可能长的时间:

{"error":"invalid_client"}

According to the documentation: http://www.meetup.com/meetup_api/auth/#oauth 根据文档: http : //www.meetup.com/meetup_api/auth/#oauth

invalid_client  = Client authentication failed

which doesn't help me know as much as i would like. 这并不能帮助我了解我想要的信息。

Basically i am dealing with Oauth 2, meetup api, php and curl. 基本上我正在处理Oauth 2,meetup api,php和curl。 The latter 2 i am reasonably comfortable with. 后者2我相当满意。

So who is at fault here? 那么,这是谁的错呢?

I can see that the code comes back 我看到代码又回来了

oauth-meetup.php?code=e7f7523c66776c41e001acd00dc48e2a&state=

as a response i just can't get a valid token. 作为回应,我只是无法获得有效的令牌。

i had a feeling it might be a SSL/cert issue so i followed this post but got this error: 我觉得这可能是SSL /证书问题,所以我关注了这篇文章,但收到此错误:

{"error":"invalid_grant","error_description":"Invalid code"}

then i set 然后我开始

CURLOPT_SSL_VERIFYPEER => FALSE,
CURLOPT_SSL_VERIFYHOST => 0

no difference. 没有不同。

The issue must surely be isolated to my setup, however i really need help, i want to attach the code here if you can please help me! 这个问题一定要隔离到我的设置中,但是我确实需要帮助,如果您可以请帮助我,我想在此处附加代码

Looking at the code in the link: can you verify that you use the correct client_id and client_secret and that they don't contain "special" characters, such as & ? 查看链接中的代码:是否可以验证使用了正确的client_idclient_secret并且它们不包含“特殊”字符,例如& Since the code in socialmedia_oauth_connect.php does not properly URL-encode the client_id and client_secret that is a problem when their values contain characters that are not URL-safe. 由于socialmedia_oauth_connect.php中的代码无法正确地对client_idclient_secret进行URL编码,因此当它们的值包含不安全的字符时会出现问题。

The problem was encoding. 问题是编码。

Use either http_build_query: 使用http_build_query:

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

or 要么

        ."&redirect_uri=".urlencode($this->redirect_uri)

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

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