Is it possible to make 3 Legged OAuth in Google Functions - oauth-2.0

I am developing a ChatBot using Dialogflow. I will integrate it with Autodesk Forge API which needs 3 legged OAuth. I am using Dialogflow fulfillment which is a google cloud function (serverless). I am sending a URL for authentication after the user signs up, it turns to callback URL with URL + code. Is there a way to catch this parameter in URL in a serverless system like Google Cloud Functions.
(I am using node.js).

From Autodesk Forge side, you will need to use OAuth with implicit grant, which returns the access_token as part of the URL. See this tutorial.

Related

Oauth2 flow for native app with back-end web app calling Graph API

I have the following set up:
A web app (Jetty/Java)
A native client (iOS) (calling my webapp)
The Microsoft Graph API (called from my webapp)
The idea is that the user should sign in with OpenID/Oauth2 using his/her Office 365 credentials. The webapp will then call the Microsoft Graph API on behalf of the user (offline as well).
To achieve this I'm pretty sure I need to use the grant type: "Authorization code grant".
I can find a lot of example of the Oauth2 flow for browser based apps, and for when the native app calls the Graph API directly... but I want my backend to call the Graph API (and hold the access & refresh tokens).
So the question is how to do this properly? Here is my idea at this point.
From the native app: open a browser, call my web server which will trigger a redirect to the Azure /authorize endpoint (example: https://login.microsoftonline.com/[tenant]/oauth2/v2.0/authorize?client_id=[clientid]&response_type=code&scope=offline_access%20user.read%20calendars.readwrite&response_mode=query&state=12345&redirect_uri=my-scheme://oath2-code-reply
This will trigger authentication/authorization and then send the access code back to the app (using a custom scheme redirect: my-scheme://oath2-code-reply).
The app can then call my web app with this access code, where we can exchange the code for refresh & access code, and also create our own session for the user.
Is this the correct way?
Or should the entire flow occur in the browser and as the final step I open the app again with something like myapp-scheme://?sessionid=[our-own-session]?
For your scenario, you should use the on-behalf-of-flow.
A server-side sample that you can use as reference is https://github.com/Azure-Samples/active-directory-dotnet-webapi-onbehalfof - a note is that this sample is a .NET sample using a JavaScript SPA as a client - but hopefully it can guide you. You can use this sample for an overview on how to request tokens for your web api.
A note is that your item '1.' suggests that you are using the 'v2' endpoint. The 'v2' endpoint has some limitations, including for the scenario you are trying to accomplish (request access token to a Web API) - please see this document with information on these limitations, therefore my recommendation is to use the v1 endpoint at this moment for your scenarios -- which mean that you can only authenticate corporate accounts (and not MSA). The documents and samples I've indicated above uses the v1 endpoint.

Paw Not Switching Between Different Google OAuth Users

I'm trying to test connecting to a Google API on behalf of different Google accounts from the same Google Cloud Project.
I tried using different OAuth client IDs in the OAuth 2.0 as different environmental values but that's not working.
It seems the built-in web browser auto-authorizes for the last Google user who was signed in.
Is there a way for me to force Paw to redo the OAuth user flow?

Link the api.ai agent to Facebook

I am creating an api agent and I wanted to add functionality to the webhook to be able to talk to Facebook graph api. In order to do that, I want the specific intent to require a sign-in to Facebook before calling the webhook. That way it would have the token to make the API calls to Graph API.
Any idea how I can do that?
I cannot find the authorization url, token url and client secret needed for OAuth linking.
Currently, you have to own the OAuth endpoint for it to work with actions, so using the Facebook OAuth is not supported.

Three legged oauth flow on mobile app

I have a 3-legged auth flow working on a web app of mine. It goes as follows:
Use clicks Connect with Google
They accept on the OAuth dialog that Google Provides
The page gets redirect to my backend's /oauth/google endpoint with a code parameter which I send to Google to get a refresh_token so I can access data (like calendar info) on their behalf
I redirect back to the web app passing my own JWT token in the URL.
Whenever the web app makes a request like api.mybackend.com/me they use the JWT token I provided
I'm trying to accomplish something similar in a mobile app. What's the acceptable way to do this? Is it pretty much the same logic?
If it helps, my backend is Ruby on Rails and I'm writing the mobile app in Swift.
Thanks!
If you're using NSURLSession to make HTTP requests, then see this for information about handling redirects.
Google also has some pre-built Google Sign-In packages for iOS and Android that you can include in your app, similar to the one in your web client. I've never used them though, so I don't how exactly they'd integrate with you app.
Alternatively you can set up an authentication endpoint in your backend that handles the whole thing, with the app only ever making one request to your server and your server handling communication with Google. So, for example, you could have the user submit a request to /oauth/mobile. The server then submits an authentication request to Google and gets an access token and a refresh token. Then you can return your own app's token from the server. Google has some documentation on Google Sign-In for server-side apps that may be relevant.

Google Translator API OAuth Authentication

Iam developing a multi lingual application and planning to use google translator API. I was wondering if Google Translate API supports OAuth authentication or not, document is available for using key but no information is available regarding OAuth authentication.
Thanks

Resources