alecswan | 1 Jul 21:25 2013
Picon

AngularJS: How to clear query parameters in the URL?

Sorry for the crosspost with Stackoverflow, but I didn't get any answers there in a couple of days. I will reference the answer and close the other thread.


My AngularJS application needs to have access to the user's LinkedIn profile. In order to do that I need to redirect the user to a LinkedIn URL which contains a callback redirect_uri parameter which will tell LinkedIn to redirect the user back to my webapp and include a "code" query param in the URL. It's a traditional Oauth 2.0 flow.

Everything works great except that LinkedIn redirects the user back to the following URL:

    http://localhost:8080/?code=XXX&state=YYY#/users/123/providers/LinkedIn/social-sites

I would like to remove ?code=XXX&state=YYY from the URL in order to make it clean. The user does not need to see the query parameters I received from LinkedIn redirect. 

I tried $location.absUrl($location.path() + $location.hash()).replace(), but it keep the query params in the URL.

I am also unable to extract the query parameters, e.g. "code", using ($location.search()).code.
It seems like having ? before # in the URL above is tricking Angular.

Any help will be greatly appreciated.

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscribe <at> googlegroups.com.
To post to this group, send email to angular <at> googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Rodrigo Kochenburger | 1 Jul 22:18 2013
Picon

Re: AngularJS: How to clear query parameters in the URL?

If you're interacting w/ LinkedIn OAuth authorization server directly from Javascript, then you want to use the implicit grant flow: http://tools.ietf.org/html/draft-ietf-oauth-v2-31#section-1.3.2


If you're handling on the server side than you can just redirect to the client url, which does not include the code/state, after handling it.

Cheers

On Monday, July 1, 2013 12:25:19 PM UTC-7, alec... <at> gmail.com wrote:
Sorry for the crosspost with Stackoverflow, but I didn't get any answers there in a couple of days. I will reference the answer and close the other thread.

My AngularJS application needs to have access to the user's LinkedIn profile. In order to do that I need to redirect the user to a LinkedIn URL which contains a callback redirect_uri parameter which will tell LinkedIn to redirect the user back to my webapp and include a "code" query param in the URL. It's a traditional Oauth 2.0 flow.

Everything works great except that LinkedIn redirects the user back to the following URL:


I would like to remove ?code=XXX&state=YYY from the URL in order to make it clean. The user does not need to see the query parameters I received from LinkedIn redirect. 

I tried $location.absUrl($location.path() + $location.hash()).replace(), but it keep the query params in the URL.

I am also unable to extract the query parameters, e.g. "code", using ($location.search()).code.
It seems like having ? before # in the URL above is tricking Angular.

Any help will be greatly appreciated.

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscribe <at> googlegroups.com.
To post to this group, send email to angular <at> googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
alecswan | 4 Jul 01:32 2013
Picon

Re: AngularJS: How to clear query parameters in the URL?

Thanks, Rodrigo. I ended up implementing your server-side option where LinkedIn redirects to my GET REST method, which stores authorizationCode and redirects the user to a page without query parameters.


However, I am still curious if it is possible to clear URL query parameters with Angular?

Thanks,

Alec

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscribe <at> googlegroups.com.
To post to this group, send email to angular <at> googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Josh David Miller | 4 Jul 01:58 2013

Re: Re: AngularJS: How to clear query parameters in the URL?

Hello!

If you're using html5 mode, then there is no difference between standard query parameters and AngularJS ones. So your redirected URL would have looked like this:

http://localhost:8080/users/123/providers/LinkedIn/social-sites?code=XXX&state=YYY

And then you could clear the search/query parameters normally:

$location.search( 'code', null );
$location.search( 'state', null );

But I don't know of any built-in way to clear query parameters without html5 mode.

Josh
(Sent from my mobile)

On Jul 3, 2013 4:32 PM, <alecswan <at> gmail.com> wrote:
Thanks, Rodrigo. I ended up implementing your server-side option where LinkedIn redirects to my GET REST method, which stores authorizationCode and redirects the user to a page without query parameters.

However, I am still curious if it is possible to clear URL query parameters with Angular?

Thanks,

Alec

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscribe <at> googlegroups.com.
To post to this group, send email to angular <at> googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscribe <at> googlegroups.com.
To post to this group, send email to angular <at> googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Rodrigo Kochenburger | 4 Jul 02:02 2013
Picon

Re: Re: AngularJS: How to clear query parameters in the URL?

AFAIK there is no way to alter the URL through js without causing a redirect, besides using HTML5's history api.

On Wednesday, July 3, 2013 4:58:03 PM UTC-7, Josh David Miller wrote:

Hello!

If you're using html5 mode, then there is no difference between standard query parameters and AngularJS ones. So your redirected URL would have looked like this:

http://localhost:8080/users/123/providers/LinkedIn/social-sites?code=XXX&state=YYY

And then you could clear the search/query parameters normally:

$location.search( 'code', null );
$location.search( 'state', null );

But I don't know of any built-in way to clear query parameters without html5 mode.

Josh
(Sent from my mobile)

On Jul 3, 2013 4:32 PM, <alec... <at> gmail.com> wrote:
Thanks, Rodrigo. I ended up implementing your server-side option where LinkedIn redirects to my GET REST method, which stores authorizationCode and redirects the user to a page without query parameters.

However, I am still curious if it is possible to clear URL query parameters with Angular?

Thanks,

Alec

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u... <at> googlegroups.com.
To post to this group, send email to ang... <at> googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscribe <at> googlegroups.com.
To post to this group, send email to angular <at> googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
alecswan | 4 Jul 04:04 2013
Picon

Re: Re: AngularJS: How to clear query parameters in the URL?

Thank you all for responding.

Michael Wulf | 4 Jul 17:03 2013
Picon

Re: AngularJS: How to clear query parameters in the URL?

I haven't enabled HTML5 in my Angular, but I was able to clear a search param by using the following setup:


// in the routing calls, add reloadOnSearch=false
$routeProvider.when('/about', {
            templateUrl: 'partials/about.html',
            controller: 'Controller'
            reloadOnSearch: false
         });

Now to remove the search, I use the same approach others have noted:

$location.replace();
$location.search('term', null);

Hope that's helpful to someone else; it saved my bacon.

On Monday, July 1, 2013 12:25:19 PM UTC-7, alec... <at> gmail.com wrote:
Sorry for the crosspost with Stackoverflow, but I didn't get any answers there in a couple of days. I will reference the answer and close the other thread.

My AngularJS application needs to have access to the user's LinkedIn profile. In order to do that I need to redirect the user to a LinkedIn URL which contains a callback redirect_uri parameter which will tell LinkedIn to redirect the user back to my webapp and include a "code" query param in the URL. It's a traditional Oauth 2.0 flow.

Everything works great except that LinkedIn redirects the user back to the following URL:


I would like to remove ?code=XXX&state=YYY from the URL in order to make it clean. The user does not need to see the query parameters I received from LinkedIn redirect. 

I tried $location.absUrl($location.path() + $location.hash()).replace(), but it keep the query params in the URL.

I am also unable to extract the query parameters, e.g. "code", using ($location.search()).code.
It seems like having ? before # in the URL above is tricking Angular.

Any help will be greatly appreciated.

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscribe <at> googlegroups.com.
To post to this group, send email to angular <at> googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
fess | 4 Jul 20:01 2013
Picon

Re: Re: AngularJS: How to clear query parameters in the URL?

I think this will  remove a search param stored in the hash:

   http://domain.com/base.index.html#!?search=blah

but it can't be used to remove one stored in the url 

   http://domain.com/base.index.html?search=blah

changing anything but the hash without html5 history will result in a browser reload.

(correct me if  I'm wrong.) 

--fess

On Jul 4, 2013, at 8:03 AM, Michael Wulf wrote:

> I haven't enabled HTML5 in my Angular, but I was able to clear a search param by using the following setup:
> 
> // in the routing calls, add reloadOnSearch=false
> $routeProvider.when('/about', {
>             templateUrl: 'partials/about.html',
>             controller: 'Controller'
>             reloadOnSearch: false
>          });
> 
> Now to remove the search, I use the same approach others have noted:
> 
> $location.replace();
> $location.search('term', null);
> 
> Hope that's helpful to someone else; it saved my bacon.
> 
> On Monday, July 1, 2013 12:25:19 PM UTC-7, alec... <at> gmail.com wrote:
> Sorry for the crosspost with Stackoverflow, but I didn't get any answers there in a couple of days. I will
reference the answer and close the other thread.
> 
> My AngularJS application needs to have access to the user's LinkedIn profile. In order to do that I need to
redirect the user to a LinkedIn URL which contains a callback redirect_uri parameter which will tell
LinkedIn to redirect the user back to my webapp and include a "code" query param in the URL. It's a
traditional Oauth 2.0 flow.
> 
> Everything works great except that LinkedIn redirects the user back to the following URL:
> 
>     http://localhost:8080/?code=XXX&state=YYY#/users/123/providers/LinkedIn/social-sites
> 
> I would like to remove ?code=XXX&state=YYY from the URL in order to make it clean. The user does not need to
see the query parameters I received from LinkedIn redirect. 
> 
> I tried $location.absUrl($location.path() + $location.hash()).replace(), but it keep the query
params in the URL.
> 
> I am also unable to extract the query parameters, e.g. "code", using ($location.search()).code.
> It seems like having ? before # in the URL above is tricking Angular.
> 
> Any help will be greatly appreciated.
> 
> -- 
> You received this message because you are subscribed to the Google Groups "AngularJS" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscribe <at> googlegroups.com.
> To post to this group, send email to angular <at> googlegroups.com.
> Visit this group at http://groups.google.com/group/angular.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

--

-- 
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscribe <at> googlegroups.com.
To post to this group, send email to angular <at> googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.

Picon

Re: AngularJS: How to clear query parameters in the URL?

Try this code
$location.url('/');
$rootScope.$apply();

вторник, 2 июля 2013 г., 1:25:19 UTC+6 пользователь alec... <at> gmail.com написал:
Sorry for the crosspost with Stackoverflow, but I didn't get any answers there in a couple of days. I will reference the answer and close the other thread.

My AngularJS application needs to have access to the user's LinkedIn profile. In order to do that I need to redirect the user to a LinkedIn URL which contains a callback redirect_uri parameter which will tell LinkedIn to redirect the user back to my webapp and include a "code" query param in the URL. It's a traditional Oauth 2.0 flow.

Everything works great except that LinkedIn redirects the user back to the following URL:


I would like to remove ?code=XXX&state=YYY from the URL in order to make it clean. The user does not need to see the query parameters I received from LinkedIn redirect. 

I tried $location.absUrl($location.path() + $location.hash()).replace(), but it keep the query params in the URL.

I am also unable to extract the query parameters, e.g. "code", using ($location.search()).code.
It seems like having ? before # in the URL above is tricking Angular.

Any help will be greatly appreciated.

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscribe <at> googlegroups.com.
To post to this group, send email to angular <at> googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.

Gmane