# Auth0 custom social connection not working with Reddit oAuth

**URL:** <https://community.auth0.com/t/auth0-custom-social-connection-not-working-with-reddit-oauth/45376>\
**Category:** Get Help\
**Tags:** custom-social-connec\
**Created:** [June 27, 2020, 4:08am UTC](https://community.auth0.com/t/auth0-custom-social-connection-not-working-with-reddit-oauth/45376 "2020-06-27T04:08:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ccb0x45](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ccb0x45/32/22217_2.png) [@ccb0x45](https://community.auth0.com/u/ccb0x45)\
**Post date:** [June 27, 2020, 4:08am UTC](https://community.auth0.com/t/auth0-custom-social-connection-not-working-with-reddit-oauth/45376/1 "2020-06-27T04:08:35Z")

</div>

Hey,’  
I am trying to create a custom social connection for reddit. My settings are:  
Auth URL: [Reddit - Please wait for verification](https://www.reddit.com/api/v1/authorize)  
Client ID:   
Secret:

Token URL: [https://www.reddit.com/api/v1/access\_token](https://www.reddit.com/api/v1/access_token)

Scope:  
identity

Fetch user profile script:  
function(accessToken, ctx, cb) {  
request.get(‘[https://oauth.reddit.com/api/v1/me](https://oauth.reddit.com/api/v1/me)’, {  
headers: {  
‘Authorization’: 'Bearer ’ + accessToken  
}  
}, function(e, r, b) {  
if (e) return cb(e);  
if (r.statusCode !== 200) return cb(new Error('StatusCode: ’ + r.statusCode));  
var profile = JSON.parse(b).data;  
profile.user\_id = profile.id;  
cb(null, profile);  
});  
}

Custom headers:  
{  
“Authorization”: “Basic \<MY AUTH BASE 64 STRING\>”

This correctly gets me to reddit authorization page and lets me allow, but fails with “invalid\_grant” “Invalid authorization code”.  
Which from here the docs say:  
`invalid_grant` The `code` has expired or already been used Ensure that you are not attempting to re-use old `code` s - they are one time use.

Would the custom social connection somehow be reusing an old code? Anyone gotten this to work?

---

<div class="post-metadata">

**Author:** ![jjmerri88](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jjmerri88/32/13389_2.png) [@jjmerri88](https://community.auth0.com/u/jjmerri88)\
**Post date:** [February 24, 2021, 1:42pm UTC](https://community.auth0.com/t/auth0-custom-social-connection-not-working-with-reddit-oauth/45376/2 "2021-02-24T13:42:43Z")

</div>

Maybe because your `User-Agent` header is missing? I was getting a 403 without it. I was able to create a Reddit social connection with the following:

Authorization URL:  
`https://www.reddit.com/api/v1/authorize`

Token URL:  
`https://www.reddit.com/api/v1/access_token`

Scope:  
`identity`

Fetch User Profile Script:

```auto
function(accessToken, ctx, cb) {
  request.get({
    url: 'https://oauth.reddit.com/api/v1/me',
    headers: {
      'Authorization': 'Bearer ' + accessToken,
      'User-Agent': 'Auth0'
    }
  }, function(e, r, b) {
    if (e) return cb(e);
    if (r.statusCode !== 200) return cb(new Error('StatusCode: ' + r.statusCode));
    var profile = JSON.parse(b);
    profile.user_id = profile.id;
    cb(null, profile);
  });
}

```

Custom Headers:

```auto
{
  "Authorization": "Basic SklBNDAtUmJhSjZBRVE6eHRkTUVyUUVFb3VoaEdFSTZVV21WVnBWV2tsM2xR"
}

```
