express - Angular: Instagram authorization - access token -


so, building app, (among other things) provide instagram, twitter, fb , yt live feeds on specific hashtag

right working on instagram (first) thinking piece of cake

  • register dev
  • register app
  • get appid , secret
  • angular http api call instagram access token (using app id , secret)
  • angular http api call instagram getfeed?hashtag=xy (using access token)...

now, obviously, not this...

  • so first of, instagram had me register app , client , redirect url
  • then need make api call code (link ... using client_id , redirect uri)
  • then go access token
  • and able normal feed api call

well, don't mind step code.... but... redirect url messing flow... don't know do...

in angular (4 cli) app, user working normally, gets profile page.... tab select social platform , feed populated... now... don't want user redirected app instagram, twitter, fb , yt... 4 times.... not once... want happen behind scenes normal api calls

so if in instagram.service.ts

getaccesstoken() {   const api = 'https://www.instagram.com/oauth/authorize/';    const params: httpparams = new httpparams()     .set('client_id', clientid)     .set('redirect_uri', 'http://localhost:4200/auth/')     .set('response_type', 'code');    return this.http.get<any[]>(api, {params})   .map((response) => response)   .catch((error: any) => observable.throw(error.error || 'server error')); } 

and call it, in developer tools see enter image description here

so api call successful, angular app not handle auth path... gives 404.... though in routes have:

  {path: 'auth', children: [     {path: ':instagramtoken', component: matcheslandingpagecomponent},     {path: '**', component: matcheslandingpagecomponent},   ] }, 

so question is, how da hell handle this? without redirects?

. . .

i using loopback express server backend (to data via restful api) .... might way in there? http://localhost:3000/api/instagram?hashtag=xy ??

first few remarks:

you won't use client_secret because using in front end application. won't secret anymore if you'd put in javascript code. in case using implicit flow.

it might useful use library that. this one.

i don't want user redirected app instagram, twitter, fb , yt... 4 times.... not once...

i'm sorry, have to. way providers know users autorized app. isn't needed before every request because can store tokens in session storage. (a library might itself.) work instagram tokens don't expire, other might not same.

now 404, redirecting http://localhost:4200/auth/?code.... isn;t correct url , want http://localhost:4200/auth?code=...

so change .set('redirect_uri', 'http://localhost:4200/auth/') .set('redirect_uri', 'http://localhost:4200/auth').


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -