Q&A

Registered LINE OAuth Callback URLs are not working

Issue/ Error Message details

I'm implementing OAuth flow with Line. Here are steps to my problem.

  1. The client side does retrieve code, state and etc from the Line auth server.
  2. The backend server receives request from the client(using graphql), and makes POST request to https://api.line.me/oauth2/v2.1/token
  3. I checked multiple times, the grant_type, code, client_id, client_secret are correctly input.
  4. The response is ALWAYS 400 bad request, 'redirect_uri does not match', EXCEPT when the redirect_uri is set to 'http://localhost/social-login(edited)'
  5. Again, the redirect_uri s are checked multiple times for debugging, and those are exactly as written in the developer console for the aforementioned client id & secret

Can anybody shed some light on this problem? Will be much appreciated!

  • 0
  • 5
  • 1089
  • twitter facebook

FOR ANYBODY WHO HAPPENED TO ARRIVE HERE WITH THE SAME PROBLEM

The problem was that the url for retrieving authorization token was different from url that asked for access token. Simply put, I was using auth token issued with url www.my-application.com whereas I was asking for access token from url http://localhost

Make sure that these two are equal.

  • 0

I think if you specify full URI (http://localhost:(port-number)/social-login) on step 2, it will work.

I stated full redirect URIs for every URIs I stated in the developer console. Here are copy & paste version of them with domain name omitted.

http://localhost:8100/hello http://localhost:8100/social-login/line http://localhost:8100/withdraw/line https://myapp1234/social-login/line https://myapp1234/withdraw/line https://myapp1234/social-login/line https://myapp1234/withdraw/line

None of the above works except for the localhost one.

  • 0

Indeed, the redirect URI is written just like you expected it to be. (http://localhost:(port-number)/social-login)

I think if you specify full URI (http://localhost:(port-number)/social-login) on step 2, it will work.

  • 0

@シュークリーム Indeed, the redirect URI is written just like you expected it to be. (http://localhost:(port-number)/social-login) I didn't specify the full URL because it wasn't so relavant to the issue.

  • 0

Is your redirect URI you used in step 1 really 'http://localhost' without any path like 'http://localhost/line/login' ? The redirect_uri parameter in step 2 should contain full URI.

  • 0

Similar posts

    No similar posts

Are you sure? question.vm