How do I callback to my own app from Spotify API? - java

I'm trying to connect to Spotify via API where I need a redirect_URI on a successfull callback. However, I'm new to this and don't really know what I should do here. I tried looking for ways on how to get the URI that refers to my app but I can't find anything. How do I get the URI that links to my app?

Redirect URL (go into your app’s settings and scroll down a bit and you’ll see an input field labeled Redirect URL. You’ll want to set this to an endpoint that your backend provides. Spotify is gonna send the user to this endpoint after the user has logged into Spotify successfully. Using a localhost URL will work if you're in dev mode.
The most apt information I found is :
https://medium.com/#stefmaxko/spotify-auth-flow-with-node-js-express-7ff13d72565a

Related

How do i whitelist a redirect URL for my android app

Im trying to work with spotify's API, with java on Android studio and one of the requirement is that i whitelist a redirect URI that the Spotify Accounts Service will use to callback to my app after authorization. I've only worked with a weather API in an android app ive built with java on android studio and i didn't whitelist a redirect URL for it, so im lost here.
Your redirect URI should be the package name of your app, with a ://callback at the end.
String REDIRECT_URI = "com.yourdomain.yourapp://callback";
This looks confusing because it is, but it does say URI not URL so it is correct.
Spotify needs to get back to your app after its authorized the user so it needs to know your app name.
For a guide:
https://developer.spotify.com/documentation/android/quick-start/
For whitelisting: https://developer.spotify.com/dashboard/

App Links on Android with the app not installed

I am trying to implement app links into my app to make sure that other malicious apps cannot register for my URL.
I read the guide on app links here https://developer.android.com/training/app-links/verify-site-associations.html and I have mostly understood it. But one thing which is not clear to me is how can I prevent malicious apps from receiving my domain links if my app is not installed.
Consider this scenario.
1. My app is not installed on the user's device
2. Some malicious app is and it knows the URL that my app handles
Wouldn't this launch the malicious app and it can intercept my URL if the user selects that app from the disambiguation dialog? Is there any way to prevent it?
I understand that android:autoVerify="true" will trigger the domain verification when the app is installed, but what if the app is not installed?
Whether the user has the app installed or not, the "illegal" app won't be able to handle your links since it has not access to your domain in order to save there the needed JSON file. Am I clear?
There is a JSON file that is required during App Link configuration, that has to be uploaded to your server (that includes your app ID), through which your web-app basically says to the Android OS 'this is my counterpart on Android devices, I authorise it to handle these URLs'. Since app IDs are unique, there is no way another app can meet those conditions.
To quote the docs:
An Android App Link is a deep link based on your website URL that has
been verified to belong to your website.
So, although an app may register an <intent-filter> it ALSO has to be verified by the website whose URL it's trying to handle. And this happens on the server, so, out of the reach of a mobile client.
See also HERE for a more detailed explanation.

YouTube Data API v3 quota exceeded on the first upload

I am trying to develop a desktop application in Java for uploading videos. I create a new Google account, create project on developer console and create credentials (ClientID and ClientSecret). After creating all of these, i do authorization (as in java examples), the application opens browser window for me to allow the application to manage the channel, and everything works fine.
But when i try to upload a video (short video, tried it on other channels before and it uploaded every time), i immediately get quota exceeded response. And in the developer console i can see that quota is actually exceeded (9644 queries already). I must add that this is happening only for the newly registered accounts - the same video uploads without issues using the same app.
Why is this happening? Is there any way I can "register" new account and immediately do upload? If not, how can I do this properly? Thanks
I had a similar problem with the python code that i used (i modified code based on https://developers.google.com/youtube/v3/guides/uploading_a_video). I solved it using the following workflow:
create a (new) google account if you dont have one yet
go to youtube, sign up with the google account and create a channel
go to
https://console.developers.google.com/apis/credentials?pli=1
create a project, pick a name
click on OAuth consent screen, pick external, pick application name
go back to Credentials, create Credentials using OAuthClient ID, pick Web application
pick a name, put into redirect urls: http://localhost:8080/ and https://developers.google.com/oauthplayground and save
go to Dashboard, search YouTube Data API v3 and enable
then go to https://developers.google.com/oauthplayground/
click on the rack wheel on the right, click use your own credentials, copy and past clientID and secret client from https://console.developers.google.com/apis/credentials and close
search for Youtube Data API v3 on the left, and select https://www.googleapis.com/auth/youtube.upload and https://www.googleapis.com/auth/youtube
click authorize APIs, log into your account, agree to all questions asked
Click Exchange authorization code for token
the Request on the right should not give you any errors
go back to https://console.developers.google.com/apis/credentials, when you click on the edit button next to your credentials, you should be able to download your JSON files. put them into the script folder under client_secrets.json
make sure to delete the file python_upload_video.py-oauth2.json from previous trys
when running the code with for example
python upload_video.py --file="input.mp4" --privacyStatus="unlisted"
the browser should open and ask you to log into your account
what i noticed is that:
if you get three errors in three hours it seems to exceed the quota and you cannot continue
the upload works for about 5 videos a day. If you need to upload more and cannot wait the only way is to create a new account and repeat the steps above (as far as I know)
It may be worth investigating further: I guess that your issue has to do with the API issues seen since about three days now. See the answer https://stackoverflow.com/a/55220182/8327971; also Google's known and acknowledged issue: https://issuetracker.google.com/issues/128673552.

Google action fulfillment url (with my own java server)

I'm trying to play with Google Home Action. I've created a new project, give it a name, then have to put a fulfillment url.
I've already implemented a small server (in Java, by using the class HttpsServer) to control a connected object in my house (it's already worked, I can send action to it by invoking a url, when I'm connected from my WIFI or outside of my home network with my 4G smartphone). The url is something like https://xxx.xxx.xxx.xxx:8080/my_object?action=test
So I've just tried to add a new "google" context to my server to do some "google action" when invoking via url https://xxx.xxx.xxx.xxx:8080/google. For now with this url, I just reply with a "OK google" string in a 200 answer and also display it locally on my console output. When invoking myself, it just display the string (by invoking it from my 4G connection).
Naively I think I just have to put my https://xxx.xxx.xxx.xxx:8080/google inside the fulfillment input box into the Google Action... and bim I will just have to understand the requests sent by Google (manage authentication, etc) to my tiny server. But when trying to invoke it via the simulator, my server is not triggered.
I must have missed something, but what?
If someone can help me, or put me to the correct direction, it would be great.
Regards
Just to resume:
Google Home Action accept only HTTPS fulfilement url.
And the https server must not use a self signed certificate.
Even with that, it never triger anything to my personal server (I've written to Google Support, answer me that tey will look... but after 1 week, problem is not solved).
My solution:
I just create an account on IFTTT, associate it to my google home account, and create a simple "applet" with if (select google assistant, input sentence I have to say), then (select webook, put the url of my server with the correct parameter in it)... save... it publish it to my google home assistant (how? I don't know and don't care)... try.. it works!
Don't know why Google do not provide something as simple as IFTTT to work with their assistant.

Get Facebook Username using Windows Azure

Hereis my problem,
I make an Android application and i use Windows Azure.
I use Azure to make login activity with Facebook. It works well i can log in.
However i want to get the Name and last name of the guy who log in using Facebook.
I have no idea how to do it using windows azure, i check this web site http://blogs.msdn.com/b/carlosfigueira/archive/2012/10/25/getting-user-information-on-azure-mobile-services.aspx
But i don't understand it. Anyone got an idea on how to get the name and last name of the person who log in using windows azure on android ?
To get user's information from facebook, first User must authorize it. Second, you need to query this information using graphs api from facebook.
Here some tutorials that could help you:
http://blogs.msdn.com/b/carlosfigueira/archive/2012/10/25/getting-user-information-on-azure-mobile-services.aspx
http://chrisrisner.com/Authentication-with-Windows-Azure-Mobile-Services
https://developers.facebook.com/docs/android/getting-started/

Categories