php - Reddit OAuth2 returning `invalid_grant` from server in production, despite working in local? -


let me preface restating error not occur in either local or online beta environment, in production; despite 3 servers sharing same following environment variables:

reddit_username=username reddit_password=pwd reddit_id=id reddit_secret=secret 

when try request reddit access token in production using method:

/**  * @internal  *  * request reddit token  *  * if client not have current valid oauth2 token, fetch 1 here. set cookie.  */ private function requestreddittoken() {     $response = $this->client->post(reddit::access_token_url, array(         'query' => [             [                 'client_id' => $this->clientid,                 'response_type' => 'code',                 'state' => bin2hex(openssl_random_pseudo_bytes(10)),                 'redirect_uri' => 'http://localhost/reddit/test.php',                 'duration' => 'permanent',                 'scope' => 'save,modposts,identity,edit,flair,history,modconfig,modflair,modlog,modposts,modwiki,mysubreddits,privatemessages,read,report,submit,subscribe,vote,wikiedit,wikiread'             ]         ],         'auth' => [$this->clientid, $this->clientsecret],         'form_params' => [             'grant_type' => 'password',             'username' => $this->username,             'password' => $this->password         ]     ));      $body = json_decode($response->getbody());     $this->tokentype = $body->token_type;     $this->accesstoken = $body->access_token;      // set cookie expire in 60 minutes.     setcookie('reddit_token', $this->tokentype . ':' . $this->accesstoken, 60 * 60 + time()); } 

i exception breaks flow of app because $response->getbody() equal invalid_grant.

yet, can't figure out why invalid, since using precise similar credentials in different environments, , using postman, result in me receiving valid access token in response. what's going on here?


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -