I am currently trying to create an application in Django that fetches emails from an Inbox using the gmail API. I was able to successfully perform this in Nodejs, but I wanted to switch to using Django. I used the Python Gmail API quickstart: https://developers.google.com/gmail/api/quickstart/python. I created a view for the function found in the tutorial and the first issue I encountered was "invalid redirect uri" which is an issue I encountered in the past, which I still don't understand. I tried editing the redirect uris in the Oauth Token to fix this issue, but it didn't work (I probably was doing it wrong). Eventually, I deleted the Oauth Token and tried creating a new GCP project but it said "Oauth Token deleted". I kept trying to create new ones (I updated the credentials.json everytime). I even tried starting a new Django project with a new GCP Project+ Oauth token, but I'm still getting the same "Oauth Token Deleted" error. I'm not sure whats going wrong and was wondering if someone with experience using the API would know what to do. Thanks!
Related
I am trying to build an python application for my server to run 24 hours and overwrite a file in dropbox every minute. When I built this application it stopped working after an hours for new token. I can't awake 24 hour to add new token every token. I just want a way that help me in doing setup of this. With dropbox there is no option to remove short length expire from token. Please keep it simple to underatnd easily dropbox documentation is hard for me to understand.
I just want a solution for this problem. I tried refresh token but it also required user interaction so no use.
Using refresh tokens is the right solution here. Just like with Dropbox access tokens, manual user interaction is required initially to get a Dropbox refresh token, but once the app has a refresh token it can store and re-use it repeatedly without further manual user interaction.
For reference, Dropbox is in the process of switching to only issuing short-lived access tokens (and optional refresh tokens) instead of long-lived access tokens. You can find more information on this migration here.
Apps can still get long-term access by requesting "offline" access though, in which case the app receives a "refresh token" that can be used to retrieve new short-lived access tokens as needed, without further manual user intervention. You can find more information in the OAuth Guide and authorization documentation.
You can find examples of using the OAuth app authorization flow in the Dropbox Python SDK here.
I am trying to hit microsoft to do list api using python program.
Api : https://graph.microsoft.com/beta/me/todo/lists , which resulted in error : Access is denied due to invalid credentials. But when I tried the api : https://graph.microsoft.com/v1.0/users, I am getting the results properly. The documentation of the api (https://learn.microsoft.com/en-us/graph/api/resources/todo-overview?view=graph-rest-beta) says "Currently, the API supports only permissions delegated by the signed-in user". Currently I am trying to get auth code and then auth token and then hitting the API. To act as signed in user, what method should I follow in python? Please note I am not using a web frame work. When I tried using flask and then hitting the API , it works. Need to know how a browserless console python application can serve the purpose.
Thank youin advance for the help
You are getting an App only token using a client credential flow and it doesn't ask for user credentials. Please check these Authentication flows and according to your requirement you can choose one of these and implement it. In other ways you can test your HTTP call in Graph Explorer by adding permissions there itself. Your call works here because you will login as user.
First Question: So, I'm attempting to post an image to a specific slack channel using the files.upload API call in the Slack APIs. I have a client_id and a client_secret. I just want this to be used for my team using slack to communicate. Is this possible without getting an access token through OAuth 2?
Secondary question: In my attempt to go through OAuth 2, I have placed my client_id into a python dictionary and then json.dumps() it. I stored the id in the field 'client_id' yet the message returned is "OAuth message: please specify a 'client_id'" Why is this an error? Should I name it something other than 'client_id'?
EDIT: I found the answer to question 2. I don't receive what I expected, but simply sending the dictionary without turning into a JSON object solved the client_id issue.
You always need an access token to upload a file with the Slack API.
But you can install your Slack app to your own Slack workspace without going through the OAuth process yourself. Just create your Slack app and go to the "Install App" page your app. Which you find under Manage your apps.
Example screenshot:
Another option (although not recommended) is to us a legacy token. You can create it here:
https://api.slack.com/custom-integrations/legacy-tokens
I'm working on a project which has it's backend on python/django and front end in react and redux with client side routing using react-router. Please suggest me some ways of doing user login authentication/validation in react with the django token generated/stored at the backend. The login flow should be something like this:
User table with email and password created in django, auth token generated by django.
User logs in for the first time, api gets called by react, on successful validation server responds with a token which I'll be storing in a session. All the subsequent calls to the api will include this token for authorization.
Secondly, I'm confused about how the secured client side routes will be authorised? On the basis of the user logged in state or what?
PS: I'm only asking suggestions for the best ways to achieve this and nothing else.
With this a year old, you may not need this, but maybe others could use it. I ran into a similar problem and wrote a package so I wouldn't have to keep writing authentication for django...
drf-redux-auth
It's just provides actions, reducers, and basic (example) components for authenticating with Django Rest Framework using token authentication.
I'd be interested to hear how you decided to handle the authorization piece with react-router...
I've managed to implement the simpleauth package for a basic webapp I've been working on. I now need to send data to this service from a python script running on a Raspberry Pi (the app is a "data logger" for temperature). Before I had implemented the simpleauth package, I could just POST the data and username to the site. Alas, now the response is the login page (to be expected).
If I wanted to connect to this webapp from the command line, I assume I'll need to authenticate myself. However, how would I go about doing this? I assume I'm going to need to programmatically replicate the steps taken by the browser to get a token but I think I've tried this and it hasn't worked. I'm not even sure who my token provider is - my webapp, or Google?
Any tips?
If you're trying to authenticate on an installed or console app, you need to use urn:ietf:wg:oauth:2.0:oob as the redirect_uri GET param in when you redirect the user to the login/authorization page. Once your app has been authorized, they'll be presented with a valid OAuth 2.0 code in a text box that they'll have to copy/paste into your app. Once they do that, then your app must follow the rest of the usual server-side flow (code for token exchange, etc.).