vimeo / vimeo.js

Official Node.js library for the Vimeo API.
https://developer.vimeo.com
Apache License 2.0
268 stars 78 forks source link

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

Open jcgaza opened 4 years ago

jcgaza commented 4 years ago

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 commented 4 years ago

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