Requesting an OAuth 2.0 access token

Hello. Please help me with requesting OAuth access token. Seems I’ve missed something.
According to docs, i should locate to
https://be.contentful.com/oauth/authorize?response_type=token&client_id=$YOUR_APPS_CLIENT_ID&redirect_uri=$YOUR_APPS_REDIRECT_URL&scope=content_management_manage
where i’ve set my client id created at https://app.contentful.com/account/profile/developers/applications
redirect_uri I’ve tried to set different ways: simple https url to my site, with encodeURI (js) and encodeURIComponent. But any tryings get me to contentful page with message An error has occurred. What I am doing wrong?

Hi Kiril,
I am trying to exactly the same with ASP.NET Core 3.1. And I have the same issues. If you have found a solution, do you mind sharing the parameters required to solve it.
I would really appreciate.
Thanks

If YOUR_APPS_CLIENT_ID is abc123 and YOUR_APPS_REDIRECT_URL is https://www.yoursite.com/app-oauth-page/ then the URL you should send your users to would be this

https://be.contentful.com/oauth/authorize?response_type=token
&client_id=abc123
&redirect_uri=https://www.yoursite.com/app-oauth-page/
&scope=content_management_manage

I’ve added some newlines in the above snippet to make it easier to read, but it should all be one line, one string without spaces.

When a user successfully authenticates against Contentful and allows the creation of the OAuth token then the webpage at https://www.yoursite.com/app-oauth-page/ will receive a request where the full request URL will contain #access_token=def456 where def456 is the OAuth token your app can now use.

If you can’t get it to work, please share more details of your setup and the errors you’re getting.

Hi Charlie, I’m having the same issue described as above. I tried doing exactly what you said, below is what I entered in the url I send users:

https://be.contentful.com/oauth/authorize?response_type=token
&client_id=/*I entered my number here */
&redirect_uri=https://localhost:3000/callback
&scope=content_management_manage

When I click on the link I am redirected to contentful but as soon as I sign it, it says “sign in successful but an error occurred” and does not redirect. The url comes back as: https://be.contentful.com/oauth/authorize?response_type=token&client_id=mynumber&redirect_uri=true%3A%2F%2Flocalhost%3A3000%2Fcallback&scope=content_management_manage&login=1#
Below is a picture of the instance and the console:

Same happening here. Did exactly what you posted and I’m still getting this error.

Incase others are stuck here. I believe the missing component the fact that localhost is being used. As stated at the bottom of Contentful’s OAuth page:
Please note that the redirect URI must be HTTPS. During the development phase of your application, you may be using localhost. We suggest using a tool like ngrok which provides a public URL and tunnel to connect to your localhost.

once install running: ngrok http 3000 will provide a https url like so: https://3232-201-142-147-11.ngrok.io which forwards to localhost:3000

I’m using ngrok and the redirect still not working, and can any one tell-me in nestjs or node how would i retrive sometinhg (access_token in this case) from a # in the url? param and query are not working. (i am a noob, and google can’t seem to help) i used the path:
https://“number from ngrok”.ngrok.io/“path”/*
so it would work even if i could retrive the token.
i tested the redirect link and its working…

any ideas?

I am literally having this same issue. Please can anyone help