one drive Redirect url not allowing query string parameters - onedrive

Currently, I'm trying to integrate the OneDrive SDK onto a website. However, I'm having issue with redirecting with authentication.
Normal route:
User goes to the website. It clicks on a button to single sign onto there OneDrive
User gets redirected to OneDrive Authorization page.
Once authentication, user gets redirected to where they left off. This redirect is specified in the OneDrive's SDK account. However, it seems that they don't allow query params in the redirect URL.
Is there a way around this?
The only thing I could figure out is using a URL that is an alias for the URL with the query params, but that just seems like a hack solution. It's hard to believe that there isn't a way for a user to redirect with query params to indicate at what stage they left off on the site.
Example of invalid redirect url as http://skydpk.com/index.php?a=ap&addon=file_sharing&page=skydrive
Any advice appreciated, Thanks, D

You can pass extra parameters through the state parameter of the /authorize request. Onedrive/Skydrive will pass back the state parameter in the last redirect to you.
So if the redirect url is
http: //skydpk.com/index.php
then your first OAuth leg looks like this:
https://login.live.com/oauth20_authorize.srf?client_id=CLIENT_ID&scope=SCOPES&response_type=code&redirect_uri=http%3A%2F%2Fskydpk.com%2Findex.php&state=state=a%3Dap%26addon%3Dfile_sharing%26page%3Dskydrive
The last OAuth leg then looks like this:
http://skydpk.com/index.php?code=AUTH_CODE&state=a%3Dap%26addon%3Dfile_sharing%26page%3Dskydrive

Related

Vue + Flask Gmail API

I am attempting to build a webapp using Vue for the frontend and Flask for the backend that reads in the users Gmail emails.
Desired functionality:
User clicks a button to "Link Gmail Account" on the frontend
User is authenticated with gmail Oauth2 and confirms. Once confirmed, they redirect back to the page they were on
Once the user confirms, the backend queries gmail to get all of the users emails and returns the data to the frontend
I have been trying to use https://developers.google.com/gmail/api/quickstart/python as a starting point, but I cannot authenticate the user -- I keep getting a redirect uri mistmatch error with a random port (I am doing this locally so have set the redirect uri to be the localhost port where I access my project).
I think I am doing something fundamentally wrong or not using the Gmail API in the correct way, but have searched all over google and youtube to no avail.
Specific things that I think could be causing an issue:
What is the best overall strategy to implement this? Should I use the Gmail API in Python or Javascript? Right now, the use clicks the "Link Account" button which calls an API in my backend which then runs the code in the Python Quickstart guide.
What kind of google project should I set up? I currently have my credentials configured for a "web application"
What should I put as the redirect uri? I am using localhost but am unsure exactly what to put here (I have tried http://localhost, http://localhost:5000, http://localhost:5000/, http://localhost:5000/emails [this is the url I want them to return to]). No matter what I put, I keep getting a redirect uri mismatch and it says the uri it is looking for is http://localhost:[random port]/
I would appreciate any help on how to approach achieving this. Thank you!
Depending on what you are going to use Gmail API for, you must select the device or category. In your case, as it is a website it should be set to "Web Application".
Also, you should be using the following redirect URI: http://localhost/emails/. You should not include the port number and you should be using trailing slashes (adding the last / at the end). Note that the redirect URI you set up in your backend must be an exact match of the one you have set up in your Credentials Page. Also please note that it might take some minutes to update this URI.
Moreover, this is a guide on how to create a Sign In button that will authorise your users that I believe will be useful for you.

URL to use for Authorised redirect URLs

What is the URL to use for Authorised redirect URLs in Google's OAuth2 API? I've tried many variations, but they all come back with: Error: redirect_uri_mismatch.
The error mentions the following URL not configured:
https://myowndomain.com/myapp/hybrid-auth/endpoint?hauth.done=Google
In the API console, I have configured these URLs at one point:
https://myowndomain.com/myapp/hybrid-auth/endpoint
https://myowndomain.com/myapp/hybrid-auth
Do I have to configure the whole URL, even the querystring? Or, perhaps this is a result of my website not accepting what Google is sending?
Edit #1
I get further now that I added the entire URL:
https://myowndomain.com/myapp/hybrid-auth/endpoint?hauth.done=Google
The configured redirect URL and the requested redirect URL must be a character-for-character match. I've never seen a URL with a query string before. Maybe it works, or maybe that's the problem. If you need to pass state through the dance, look at the state= parameter.

Pinterest redirect_uri query parameter

In my Pinterest app I have set the Redirect URI to https://my.site.com/pinterest/callback. When doing the redirection after authentication back to my site I append a sessionid so the query becomes https://my.site.com/pinterest/callback?sessionid=<string>. This doesn't seem to work as I get
The provided redirect_uri https://my.site.com/pinterest/callback?sessionId=YA6udv2FrdjjV8juij3U5oIBBP6RoEQWWUFNzSHKaHGGf3jRq10uJ2A0-R-eYB8LLwiBTbESEdGzMY0fhYI8d7gOe3kOoPuPS6c-mowaaJBDv0J8D2I does not match any of the registered redirect URIs."
In other apis like the Instagram one this is possible. Can anyone help with this? Thanks a bunch!
I have been stucking with this for two days. Basically, Pinterest doesn't support custom parameters like other websites do, for Pinterest you need to provide the EXACT callback url and it has to use https not http, and if you need to pass custom parameters they should be in state parameter.
From Pinterest docs
state: A value you define. This can be used to make sure that the redirect back to your site or app wasn’t spoofed.
See Authentication section at https://developers.pinterest.com/docs/api/overview/

Onedrive SDK Authentication Redirect Issue with Query Param

Currently, I'm trying to integrate the OneDrive SDK onto a website. However, I'm having issue with redirecting with authentication.
Normal route:
User goes to the website. It clicks on a button to single sign onto there OneDrive
User gets redirected to OneDrive Authorization page.
Once authentication, user gets redirected to where they left off. This redirect is specified in the OneDrive's SDK account. However, it seems that they don't allow query params in the redirect URL.
Is there a way around this?
The only thing I could figure out is using a URL that is an alias for the URL with the query params, but that just seems like a hack solution. It's hard to believe that there isn't a way for a user to redirect with query params to indicate at what stage they left off on the site.
Example of invalid redirect url as http://skydpk.com/index.php?a=ap&addon=file_sharing&page=skydrive
Any advice appreciated,
Thanks,
D
You can try registering your base URL as the redirect URL and just before initiating authorization action append the parameters to the redirect URL.
Redirect URL at one drive app dashboard : http://skydpk.com/index.php
Authorization URL
https://login.live.com/oauth20_authorize.srf?client_id=<your client id>&scope=<scope>&response_type=code&redirect_uri=http://skydpk.com/index.php?a=ap&addon=file_sharing&page=skydrive

socialengine v4 how to change the page members see after login

I have been trying to do this for days now and cant seem to find any help on how to do is. I want the user after login to be redirected to a different page instead of the members landing page.
Try checking the code in User/AuthController after this comment Run post login hook. There are several ways to do a custom redirect here.
specify a return_url parameter in the link to login page. You can also 64-bit encode the redirect url so that it is compact.
Keep a session variable, namely Zend_Session_Namespace('Redirect')->uri
Write a post login hook onUserLoginAfter and pass a redirect parameter in its response.
If all else fails, hard-code the next line of code which redirects to home :P