Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect URI doesn't match error, but both links match #123

Open
jcgaza opened this issue Jan 16, 2020 · 1 comment
Open

Redirect URI doesn't match error, but both links match #123

jcgaza opened this issue Jan 16, 2020 · 1 comment

Comments

@jcgaza
Copy link

jcgaza commented Jan 16, 2020

Hello. I'm trying out the API as per the documentation says. I have this error:

400 - {"error":"invalid_request",
"error_description":"The provided redirect uri does not match the one used to create the authorization code"}

This is how I initially build the address on the authorization URL, and I set the state in this:

const query = {
      redirect_uri: `https://thisisasitefortesting.com/curriculum/redirect`,
      response_type: 'code',
      client_id: process.env.VIMEO_UPLOAD_CLIENT_ID,
      scope: 'private create edit upload public',
      state: 'hello world',
    };

    const URL = `https://api.vimeo.com/oauth/authorize?${qs.stringify(query)}`;

    window.open(URL);

Then after the user allows for authentication and I get the state and code, I send the code to a Firebase function since I cannot do it client-side according to this link.

This is how I generate my access token:

try {
    const { code } = req.body;
    const options = {
      body: {
        grant_type: 'authorization_code',
        redirect_uri: 'https://thisisasitefortesting.com/curriculum/redirect',
        code,
      },
      headers: {
        Authorization: `basic ${Buffer.from(`${vimeo.upload_id}:${vimeo.upload_secret}`).toString(
          'base64'
        )}`,
        'User-Agent': 'Request-Promise',
        'Content-Type': 'application/json',
        Accept: 'application/vnd.vimeo.*+json;version=3.4',
      },
      uri: 'https://api.vimeo.com/oauth/access_token',
      json: true,
      method: 'POST',
    };

    const response = await rp(options);
    return res.json({ accessToken: response.access_token });
  } catch (error) {
    return res.status(500).json({ error });
  }

They have the same redirect URI and yet I keep on getting this error. Any help would be greatly appreciated. Thank you.

@anjan-virtism
Copy link

@jcgaza i m facing same issue. what solution did u get? please share.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants