issue with CORS on oauth flow on browser
See original GitHub issueI cant make the oauth flow to work on the browser, the issue is very similar to this
I tried to follow those instructions but I think I am doing something wrong as I am still getting this CORS issue
my flow is as follow:
- creating oauth url:
function createAuth1() {
console.log("creating auth")
const authenticationUrl = snoowrap.getAuthUrl({
clientId: 'client_id_from_reddit(installed app)',
scope: ['identity', 'wikiread', 'wikiedit'],
redirectUri: 'http://10.0.0.4:3000/',
permanent: false,
state: 'fe211bebc52eb3da9bef8db6e63104d3' // a random string, this could be validated when the user is redirected back
});
window.location = authenticationUrl
}
- after redirection extracting the
code
const code = new URL(window.location.href).searchParams.get('code')
- creating instance where
token
is the extractedcode
function createInstance(token) {
return new snoowrap({
userAgent:"Bot",
clientId:"client_id_from_reeddit(installed app)",
clientSecret:"",
refreshToken:token,
})
}
- trying to use it
const instance = createInstance(code)
console.log(await instance.getHot())
Issue Analytics
- State:
- Created 4 years ago
- Comments:11
Top Results From Across the Web
CORS issue while getting token with Oauth 2.0 Client ...
CORS issue while getting token with Oauth 2.0 Client credential flow using just React? I am able to get the Bearer token from...
Read more >Pitfalls Of OAuth2 and CORS - Medium
First, due to CORS restrictions, the server must respond with a status code other than a 302. This restriction is in place to...
Read more >OAuth 2.0 Web Server Flow and CORS problem
You're using the wrong flow. You should be using the User-Agent flow, in which you redirect to a login URL, and when the...
Read more >CORS issues with window.open() and OAuth2 - Stack Overflow
Short Answer: Check the Referer (spelling error is intentional) header in your request and response. New Chromium based browsers (Chrome, ...
Read more >Why is my fetch request to OAuth server being blocked by ...
I ran into a bunch of problems with CORS and decided to do some ... Using any sort of fetch API from a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes I changed
permanent: false
topermanent: true
and I can see it now. Well It’s all looks good. Hope this is it! Thank you very much! (:Nevermind - figured it out. For anyone else with the same problem:
The auth-code used in
fromAuthCode
can only be used once.Do Step 1 as above, then change step 2 to:
And now you can create a request object.