简体   繁体   中英

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:

{"error":"invalid_client"}

According to the documentation: 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. The latter 2 i am reasonably comfortable with.

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:

{"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 & ? 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.

The problem was encoding.

Use either http_build_query:

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

or

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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