Com.google.android.gms.auth.GoogleAuthException: UNRect_ON_API_CONSOLE

Im implements an Android application that allows users to stream to a YouTube channel directly from the application. I created an API key and an OAuth 2.0 client ID enter image description here

But I get the following exeption: com.google.android.gms.auth.GoogleAuthException: UNREGISTERED_ON_API_CONSOLE either when trying to end the event, or when trying to get manually created on the youtube channel.

I use the following code to create a youtube object

 String accountName = mContext.getString(R.string.google_account_name); String apiKey = mContext.getString(R.string.google_api_key); String clientID = mContext.getString(R.string.google_api_client_id); String clientName = mContext.getString(R.string.google_api_client_name); GoogleAccountCredential credential = GoogleAccountCredential.usingOAuth2(mContext, Arrays.asList(YouTubeScopes.YOUTUBE)); credential.setSelectedAccountName(accountName); // String SCOPE = "audience:server:client_id:" + clientID + ":api_scope:" + YouTubeScopes.YOUTUBE; // GoogleAccountCredential credential = GoogleAccountCredential.usingAudience(mContext, SCOPE); // credential.setSelectedAccountName(accountName); youtube = new YouTube.Builder(transport, jsonFactory, credential) .setApplicationName(clientName) .setYouTubeRequestInitializer(new YouTubeRequestInitializer(apiKey)) /*.setGoogleClientRequestInitializer(new YouTubeRequestInitializer(apiKey))*/ .build(); 

Then to create the event:

 LiveBroadcastSnippet broadcastSnippet = new LiveBroadcastSnippet(); broadcastSnippet.setTitle(name); broadcastSnippet.setScheduledStartTime(new DateTime(futureDate)); LiveBroadcastContentDetails contentDetails = new LiveBroadcastContentDetails(); MonitorStreamInfo monitorStream = new MonitorStreamInfo(); monitorStream.setEnableMonitorStream(false); contentDetails.setMonitorStream(monitorStream); // Create LiveBroadcastStatus with privacy status. LiveBroadcastStatus status = new LiveBroadcastStatus(); status.setPrivacyStatus("unlisted"); LiveBroadcast broadcast = new LiveBroadcast(); broadcast.setKind("youtube#liveBroadcast"); broadcast.setSnippet(broadcastSnippet); broadcast.setStatus(status); broadcast.setContentDetails(contentDetails); // Create the insert request YouTube.LiveBroadcasts.Insert liveBroadcastInsert = youtube .liveBroadcasts().insert("snippet,status,contentDetails", broadcast); // Request is executed and inserted broadcast is returned LiveBroadcast returnedBroadcast = liveBroadcastInsert.execute(); //<= This line generates the exception 

I obviously did something wrong, but I can’t understand that. Any help is appreciated. thanks in advance

+7
android android-youtube-api
source share
4 answers

The problem is that when debugging, you are using the keystore created in ~ / .android / debug.keystore and not any signature key that you think you are using.

When you create a key, for example, to release a signed APK, you think that this SHA1 is the one that is required for the Google API. This is not true.

If you replace the file in the ~ / .android folder with your signature key, it is damaged because the androiddebugkey icon is missing. FYI, the default password for the automatically generated key is "android".

For where your keystore is located, see https://developer.android.com/studio/publish/app-signing.html in the section "Expiring a Debug Certificate."

What you need to do:

1) Remove your debug.keystore and restart the IDE. This should create a new debug.keystore with the key alias "androiddebugkey".

2) If your IDE does not create a new keystore, launch the Android app. It should generate it this time in ~ / .android /

3) Go to / path / to / jre / bin and add this path to the system environment variables. This will allow you to access keytool .

4) Go to your debug repository directory and run the following command: keytool -list -keystore debug.keystore -alias androiddebugkey

5) Your console will prompt you to enter the keystore password (this is “android”).

6) Get the SHA1 key from the keystore and put that key in your API, and you will find that it works.

+9
source share

In my case, the UNRect_ON_API_CONSOLE error was caused by an error in the package name in AndroidManifest. Simple but lost many hours struggling with keys and SHA.

+6
source share

Using the answers before, I used this as a link to understand and correct mine and make a much easier step-by-step procedure for how I fixed mine.

At the windows command prompt.

Go to the java bin directory.

C: \ Program Files \ Java \ jdk1.8.0_111 \ bin>

and type ff. Team

 keytool -list -v -keystore "%USERPROFILE%\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android 

then run ff. the code

 keytool -list -keystore "%USERPROFILE%\.android\debug.keystore" -alias androiddebugkey 

when prompted for a password, enter "android" (without double quotes)

received SHA1 key from the above code. Copy it and paste it into your Google cloud console here

enter image description here

On google cloud console webpage do it

on the tab on the left, find and click "API and Services"

then on the new page, on the left tab, find and click "Credentials"

now copy the key paste that you copied from the Windows command prompt into the text box below "Subscriber certificate fingerprint"

make sure the application ID on your application and the Google Cloud Console match.

enter image description here

+2
source share

I have this problem and after a big search in build.gadle my applicationId was different from the package name that I put in the Google Console

 defaultConfig { applicationId "br.com.glicado.glicado" <-- WAS WRONG, IN MY CASE THE RIGHT IS "br.com.glicado" minSdkVersion 15 targetSdkVersion 23 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } 
0
source share

All Articles