Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keep getting Error: redirect_uri_mismatch using youtube api v3

Hi I hope someone can help me out here.

I have a Web Application (asp.net) on my local machine, I am trying to upload video to YouTube using this sample https://developers.google.com/youtube/v3/code_samples/dotnet#upload_a_video

I have set up client id and secret for Web application in Google console when I try to upload video a browser tab opens to select one of my google accounts and once I sig in I get redirect_uri_mismatch the response details on that page are below:

cookie_policy_enforce=false
scope=https://www.googleapis.com/auth/youtube.upload
response_type=code
access_type=offline
redirect_uri=http://localhost:55556/authorize/
pageId=[some page id removed here for security reasons]
display=page
client_id=[some unique id removed here for security reasons].apps.googleusercontent.com

one interesting thing is that the redirect_uri=http://localhost:55556/authorize/ is completely different from the one set up in Google console and the one in client_secrets.json also each time I get the error page the port number changes.

redurect urls and origins are set as follows in Google console I think I have added all combinations just in case:

Authorized redirect URI

http://localhost/
https://localhost/
http://localhost:50169/AddContent.aspx
https://localhost:50169/AddContent.aspx
http://localhost:50169

Authorized JavaScript origins

http://localhost/
https://localhost/
http://localhost:50169/
https://localhost:50169/

I am not sure why redirect-uri on the error page does not match any of the Authorized redirect URI I have specified in Google console ? any ideas ?

Also is it possible that everything is set-up correctly in Google console and my code but this error is triggered by something else like maybe I missed some setting on my you tube account ? I did not make any setting changes since I don't think I have to is that correct ?

like image 833
IronHide Avatar asked Apr 14 '14 11:04

IronHide


People also ask

What does Error 400 Redirect_uri_mismatch mean?

This error typically means the Client Redirect URL was not properly added to the OAuth Web Application in the Google Cloud Console. To resolve this, the user will need to copy the Client Redirect URL from the Single Sign-On Settings page from ThinkCentral, my.hrw.com, or HMH Ed.

How do I authenticate YouTube API?

First, set up your project, website, or app and then get a YouTube API key. This key will let you access YouTube's Live Streaming API. Don't forget to register your app with Google so that your API requests are successfully authenticated.

How does redirect URI work?

A redirect URI, or reply URL, is the location where the authorization server sends the user once the app has been successfully authorized and granted an authorization code or access token.


1 Answers

Ok I belive that direct video upload to the website owner account is no longer supported in YT API v3.0 according to those posts.

Can YouTube Direct Upload to a Common Account for All Users?

How can I get the youtube webcam widget to upload to one account using API?

Shame, I think I will need to host the videos that users upload on my servers.

However the original issue was fixed by adding this URI to the redirect URIs in the developer console

http://localhost/authorize/

Google OAuth 2 authorization - Error: redirect_uri_mismatch

like image 189
IronHide Avatar answered Sep 21 '22 08:09

IronHide