I'm trying to run a python script that uses spotipy, which needs a url link to be opened to authenticate the login. unfortunately I'm running this on the google cloud shell, so I can't open the browser link. and for some reason when I open it in my browser, it just redirects to localhost and doesn't authenticate (localhost is the Redirect URI). how can I authenticate?
I've tried opening the link on my MacBook instead of the linux virtual machine but just got redirected to localhost and nothing happens. I've tried xdg-open, curl, but haven't gotten anywhere.
Edit: I tried this -
import spotipy
import spotipy.util as util
from config import CLIENT_ID, CLIENT_SECRET, PLAY_LIST, USER
import random
token = util.oauth2.SpotifyClientCredentials(client_id=CLIENT_ID, client_secret=CLIENT_SECRET)
cache_token = token.get_access_token()
spotify = spotipy.Spotify(cache_token)
results1 = spotify.user_playlist_tracks(USER, PLAY_LIST, limit=100, offset=0)
But got the error that only valid bearer authentication is accepted, so apparently it's kind of working. I'm not sure how to make the bearer valid.
Edit 2:
Solved it with these posts:
How to auth in spotipy without open web browser?
Persistent issues with Spotify Web API redirect URI
Related
I am implementing WeChat SSO for my web application, I have developer account, created an application there, followed this article exactly. I am using React on front-end and flask on backend.
I am using this package for flask for WeChat-sso.
So in my weChat dashboard I have registered official website e.g (chess.com), but I have to use callback url in such way so I can test redirection on my dev server.
My dev front-end is on (localhost:8000/)
My backend server is running on (127.0.0.1:5050/)
I have tried saving different callback urls e.g (127.0.0.1:5050/api/users/wechat/callback), no matter what I save in callback url always receiving parameter error.
So my question is how do I actually achieve this functionality locally? Instead of parameter error I should be seeing QR code so that I can get code from which I can get access_token. Following code generates authentication url
from weixin import WXAPPAPI
from weixin.lib.wxcrypt import WXBizDataCrypt
from weixin.client import WeixinAPI
scope = ("snsapi_login",)
api = WeixinAPI(appid=WECHAT_APP_ID,
app_secret=WECHAT_APP_SECRET,
redirect_uri=WECHAT_REDIRECT_URI)
authorize_url = api.get_authorize_url(scope=scope)
The authentication url generated is as follows, redirect URI is properly encoded just like in the documentation.
https://open.weixin.qq.com/connect/qrconnect?appid=wx35c78a124e8f027b&redirect_uri=127.0.0.1%3A5050%2Fapi%2Fusers%2Fwechat%2Fcallback&response_type=code&scope=snsapi_base&state=689db1f29605481a492639e98c7b1f9f#wechat_redirect
Please look at the picture of error as well thanks
In my django project I have added google authentication API for user login and have deployed that project in heroku server[https://artgreeh.herokuapp.com]. I tried login through Google it worked with no issue in some machine but it's showing error in other machine. error image. In the google I have given redirect url-"https://artgreeh.herokuapp.com/accounts/google/login/callback/". If something is wrong with redirect url then it should not work in any device but it's working in some device.
I replaced "https" with "http" in the redirect url and it worked.
I am using django-rest-auth which uses django-allauth for social logins. I set login for facebook according the rest-auth documentation. This is a view. Authentication works, but the email for the user was empty. So I add callback_url and client_class (like documentation said).
from rest_auth.registration.views import SocialLoginView
from allauth.socialaccount.providers.oauth2.client import OAuth2Client
class FacebookLogin(SocialLoginView):
adapter_class = FacebookOAuth2Adapter
callback_url = 'http://localhost:8000/rest-auth/facebook/'
client_class = OAuth2Client
But it is not working. It returns this error:
Error validating verification code. Please make sure your redirect_uri is identical to the one you used in the OAuth dialog request
First I think the problem is in the library. So I printed out all parameters for the request and I check all these things. Everything looks fine, so I tried to put the URL with these parameters to Facebook Graph API. But the error is the same. Here is the all URL which I tried manually, without using the allauth library:
https://graph.facebook.com/v2.10/oauth/access_token?redirect_uri=http://localhost:8000/rest-auth/facebook/&client_id=203192345223034931&client_secret=a475bbbscds65437c89bf04d359d98a&code=203192345223034931|l3ujbbbscdhrf0404d3B2de57Dw
cliend_id and client_secret I took from Facebook developers console from Dashboard. And the code is App Token from here
In the facebook developers interface I set:
Valid OAuth redirect URIs: http://localhost:8000/rest-auth/facebook/
App domains: localhost
Because I tried it manually in my browser I hope it won't be a problem with libraries but with my settings or my misunderstanding of something.
I tried it with the normal domain, but it has not come any change.
I am building a rest api that gets authorization code from Android app and send id to google to exchange IT for Access token. It aims to provide registration with google. I am using for it two libraries:
djangorestframework-oauth==1.1.0
django-rest-auth==0.9.1
This is implementation of my login/register class
class GoogleLogin(SocialLoginView):
adapter_class = GoogleOAuth2Adapter
client_class = OAuth2Client
callback_url = 'http://localhost:8000/v1/accounts/google/login/callback/'
I set everything in
https://console.developers.google.com/apis/credentials?project=testserwusapp
I created Id client 0Auth for web applicatio. I added
http://localhost:8000
to authorized javascript sourced and
http://localhost:8000/v1/accounts/google/login/callback/
to Authorized redirect URI.
I tried many variations of those links. Both with slash and without slash in the end.
I set both client id and client secret key in my django app. However, I get Error=redirect_uri mismatch trying to exchange auth_code for access_code.
What is more I tried to use ngrok to publish my ip. I though that maybe google won't work with localhost but it didn't help.
I have deployed a Shiny app using shinyapps.io and have made the application private. I can logon to the app using my credentials and use the app, but I am not able to logout of the app.
When I try to out logout of the app I am redirected to the following link:
https://userName.shinyapps.io/appName/__logout__
And the result of this redirect is: Not Found.
I tried to search online( shinyapps-users google group, and Stackoverflow) but failed to get any info.